C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform.

learn more… | top users | synonyms

3
votes
1answer
21 views

WebApi Get with paging

How can I improve this code? ...
4
votes
1answer
81 views

Abort thread on new request, but complete only last request

The situation is that a certain asynchronous operation is called multiple times, which is basically to consolidate results. But I want to abort every time a new request comes in, which means that only ...
-3
votes
0answers
26 views
4
votes
2answers
57 views

App settings helper

The helper should be able to set a default value if the value can't be fetched with the provided key. There is also a bool that will throw an error if the key value or the default value could not be ...
8
votes
1answer
83 views

Pattern-finding game

This is a game that is supposed to be based on strategy and guessing. The letters need to match in a ABCD fashion on each button on buttons[0] - ...
5
votes
0answers
84 views

JSON parser in C#

I've writen a C# JSON parser, but its performance is not as good as JSON.NET. Running the same test, my parser takes 278 ms and JSON.NET takes 24 ms. What should I do to optimize it? It seems that ...
4
votes
1answer
48 views

SQL Permission Handling in WinForms

For my application, I've opted to use Integrated Security with Windows Authentication to access the SQL database. I've created AD security groups for each role and given them ...
2
votes
1answer
44 views

Workflow class with Start(), Continue(), and Resume() methods

I have a session class that needs to be setup based on different needs of the client code. Sometimes a new session needs to be created, or continued, or resumed (loaded from database after a user has ...
0
votes
0answers
35 views

Observable collection async update [on hold]

Is it good solution for updating ObservableCollection? Are there any dangers hiding in this code? ...
6
votes
5answers
612 views

Checking if a text contains N consecutive repeating characters

I want to check a text for consecutive repeating characters. For example, with a minimum of 3 consecutive chars, this should match: Okeee OOOkee Alsoook This should not match: No not okee, oh ...
6
votes
1answer
82 views

SQL code reuse with C#

I have some code that allows for SQL reuse for C#. I'm pretty happy with it, but the fact that I can't find anything similar on the web makes me think I'm going about it the wrong way. I have a GitHub ...
3
votes
1answer
48 views

Tic Tac Toe with winforms

This game works out the basic of a Tic Tac Toe game. I am looking to see if this can be redone in any way to make the code more smaller since this is really big. ...
0
votes
1answer
35 views

When only an Async method is available [on hold]

I have a Windows 10 Universal App (IoT) project with a class called SignalQueue. My class requires a file called MyFile.txt so I ...
6
votes
2answers
86 views

Storing an integer counter in indexer

I've been implementing a custom internal server error page in ASP.Net MVC which will check if the current user is either an administrator or accessing the page from localhost, and if so, show them a ...
10
votes
4answers
802 views

Search query utilizing menus and checkboxes

I'm dealing with a searching query where the user will pick from menus and checkboxes the variables-criteria I'm passing to the toWeb method and a list will be ...
9
votes
3answers
355 views

Chances to gain yards (text simulation game)

I'm making a text simulation game in C# and I've made the calculations and all. But I know there's a better, faster and more efficient way in doing this. Basically, the first calc is that there's a ...
8
votes
5answers
195 views

Nested object to hierarchical object list

I have a C# type to generate Layer SubLayer: ...
3
votes
3answers
344 views

Convert a date string to a DateTime object in C#

I was just wondering if my code contains defects or if there was a more efficient or general way to convert string to DateTime object. In the input, I have a string ...
0
votes
1answer
93 views

WPF ugly event dictionary

I have a WPF application that gets data from a web-server. It contains two Views LeftView RightView three Models ...
0
votes
1answer
52 views

Binding data in a TemplateField

This is my current RowDataBound function. I think this functionality is a bit horrrendous really and it winds up with an extreme amount of LINQ SQL queries being ...
2
votes
0answers
26 views

C++ std::setprecision in C# [migrated]

I'm picking up C# by porting some legacy C++ code and would like to keep the output identical. What used to be something along the lines of ...
4
votes
2answers
86 views

Setting the value of properties via reflection

I am working on an application in which I have to parse an XML file. Nodes of the XML file corresponds to an object. I have to populate the properties of the objects at run time. The code below ...
8
votes
1answer
80 views

TestExplorer 2.0 - From Grid to TreeView

Rubberduck's unit testing feature (heck, the whole project) started with a VBA unit testing framework that was ported from vba to c#; the VBA logic was pretty much simply rewritten in another ...
4
votes
1answer
62 views

Short hash generator

I am working on some code that will generate a link with a relativly unique 10 character hash. I am not worried to much about colisions as long as they are rare enough that I could have a couple ...
12
votes
2answers
125 views

Jacks or Better

This is a start towards implementing a poker-like game called Jacks Or Better. Before proceeding to improve the way cards are shuffled and dealt, I would really appreciate help cleaning up my code. ...
9
votes
1answer
100 views

Calculating and displaying score statistics using C# 6.0 features

I'm studying C# and trying to work on efficiency and making the best use of C# 6.0 features. I have created the following program based on an exercise challenge in a book, and have used Resharper to ...
6
votes
1answer
92 views

Random String Generation - Base36 and optimization

This is some fairly heavily optimized C#. Aside from reading like C++ code due to all of the pointers, does this pass sanity checks, and is there any way to improve it, while keeping its speed (or ...
3
votes
1answer
67 views

Storing user settings using LINQ to XML

I want to store some user settings into a file, so that the users get the same experience on all machines they're working on. The built-in user.config turned out to ...
2
votes
3answers
129 views

Number to Word Application in C#

I've created a Windows Form Number to Word converter application in C# which converts any number from 0 to 1 million. I would love a review based on efficiency and best practices. MainInterface.cs ...
4
votes
2answers
53 views

InfixDictionary: Data structure for Infix string lookup

I needed a data structure to quickly find all previously inserted values, that have the given string as key or substring (full text search). At first, I tried out some tree structures (infix ...
2
votes
3answers
65 views

Showing the path of a projectile

I'm trying to dive deeper into C#, and so I've been experimenting with some code. I'm creating a console application that shows the path of a projectile depending on the angle, and it works great! You ...
-4
votes
0answers
19 views

Code for Accessing a function from Unmanaged dll [closed]

The following code accesses a function from an unmanaged dll. ...
6
votes
1answer
61 views

Cleaning up HTML created by users

I have a system that accepts free text from users. This can either be plain text or a heavily limited subset of HTML. I've written the below with Html Agility Pack and Microsoft's AntiXss library. I ...
3
votes
2answers
47 views

Calculate pairs in a Set (“Sherlock and Pairs” HackerRank challenge)

Here is my second attempt at writing clean code for "Sherlock and Pairs" challenge. For my previous thread please look here: Calculate pairs in a Set ("Sherlock and Pairs" HackerRank ...
4
votes
4answers
559 views

DuplicateDictionary - A dictionary-like class which allows duplicates

Since I couldn't find any good answers I made my own class called DuplicateDictionary for personal usage. I would like some tips to improve it. ...
5
votes
2answers
252 views

Function to toggle between two values of an enum

I have this code, but it looks a bit verbose: enum MonitoringMode { Seek, Destroy } ...
1
vote
1answer
41 views

UI error display window with task async in WPF

I am new to async and was wondering if any improvement can be made to the solution I put together from scattered information on the web. The following (working) code shows how a button press runs ...
3
votes
2answers
43 views

Order Retrieval System with a SharePoint Backend

I have an ordering system that uses SharePoint. Below I've included a small snapshot of the system that is used in a WPF form when the user clicks a button to refresh the order listing. The outcome is ...
3
votes
1answer
54 views

Simple Vector2 structures (and interface)

I built a couple Vector2 structures (Vector2 and Vector2F) for use with a particular ...
7
votes
1answer
93 views

Console Calculator in C#

This is a calculator I've made in C#. Is there any way to improve it? Surely there is a way to get rid of all the ifs that are nested inside one another. ...
0
votes
0answers
11 views

Should an application configuration interface be broken into multiple interfaces to reduce feature creep? [migrated]

My windows service is neatly separated into 5 components each with their own interface, all pulled together by a bootstrapper. One of my requirements is to provide configuration options in my ...
2
votes
1answer
58 views

WPF MVVM Navigation

Following a lot of research and mainly based on this tutorial I came up with the following structure in my application: ObjectBase - all view models inherit it: ...
2
votes
3answers
535 views

Percentage calculation

What would be the best way to refactor following methods? ...
4
votes
2answers
202 views

Manipulating each value in a 2D array

This code is about manipulating each value in a 2D array. My method below is called based on how I want the values in the array to be manipulated (process). For the first method in the switch ...
6
votes
2answers
291 views

Tic-Tac-Toe game in C#

I've been learning C#, and today I made a simple Tic Tac Toe game. The code is pretty long, and I'm almost 100% positive that this can be done so much better. Please provide some advice, suggestions, ...
5
votes
1answer
81 views

Inventories, Containers and Filters

Coming off a comment on this question, I figure it cannot hurt to post my Inventory work here as well. Basically, I have Item, ...
4
votes
1answer
100 views

Performance Byte[] to Generic

I'm in need to make a byte[] -> T extension method and need it to be fast (no need for it being pretty) This function will be ...
15
votes
4answers
386 views

Entities and the things they do

So I have an Entity, which is responsible for providing an abstract base for other objects to inherit. (Like Actor objects, ...
1
vote
1answer
68 views

Windows Service listening for messages from a network

I am new with async task in C# 4.5 and feel insecure about this: I want to create a Windows Service that listen messages from a network (similar to msmq for example), when a message is received, do ...
5
votes
2answers
88 views

Base service for two different implementations

I have code that fetches different templates for HTML and CSS in the file system. The templates are stored in different folders, so I have two implementations for the code that fetches them, passing ...