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

2
votes
0answers
29 views

Use of Async/Await for EventHandlers

I have a MVC WinForms application. I am using Dependency Injection with Ninject as the IoC container. ...
1
vote
0answers
30 views

SqlCommand filter by dates are slow

I have these codes(.net framework 2.0): ...
0
votes
0answers
19 views

Bootstrapped tabbed table view

This produces tabbed tables. Here's how it looks: Each table displays comments of E-commerce products. The variable dtProductComments is ...
5
votes
3answers
107 views

Console RPG - show cycle optimization

I have this RPG game and this has elements such as the map, the monsters and the items. The monsters and the items are stored in Lists and every time I want to show ...
4
votes
1answer
32 views

Active Directory Tool - Wpf application to query active directory and display results 2 (UI)

This is an update from here. I have made some changes, and have decided to only include the UI side of things in this particular question. I wanted to make the application follow the MVVM pattern, but ...
8
votes
4answers
133 views

Project Euler 4: Largest palindrome product

This solves Project Euler 4: Largest palindrome product using C# (specifically, using LINQPad). Any and all suggestions for improvements to either the C# code or the math/algorithm are very welcome. ...
5
votes
2answers
1k views

C# - Job Pipeline

We have a Console Application which runs to perform an Incremental load of our data warehouse staging area, with data from a number of production databases. The source database don't necessarily have ...
2
votes
1answer
69 views

Moving a player around a board, by choice and by chance

Recently I had to add 2 different sets of logic for moving my player around the board. One lets the player pick a location and move him there while the other uses a dice. I'm reusing code for both ...
4
votes
3answers
105 views

Parsing remote text file and inserting into database table

I did run this code through StyleCop. Goal was to optimize the reading, parsing and inserting of a file on the web and write the rows to a database table using a stored procedure. Contrast this (...
4
votes
0answers
58 views

GET with paging, sorting and filtering

I have a GET method that handles paging, filtering, and sorting. Development has been fairly rapid and I'm not completely sold on some of the implementation. A few assumptions have to be made for this ...
-1
votes
0answers
42 views

c# Builder Pattern Usage Validation [on hold]

I have below class which builds reference data for my app, do you think it's a good implementation of builder pattern. What can I change to improve it? ...
3
votes
5answers
632 views

Class with TryParse static method

I am receiving and Expression (String) as follows: String expression = "+name;-age;-city"; I parse this expression by splitting it using ...
0
votes
1answer
44 views

Guided object builder

Sometimes when designing a fluent-api it's important to build an object in a specific way/sequence. I tried to create such a guided builder and came-up with this: ...
1
vote
3answers
173 views

ASP.NET Product Listing

I am working on a e-shop in ASP.NET MVC, and I just made the listing of product the way I figured out this night. Is it correct? Or should I make it differently? How? So this is my Product controller,...
13
votes
2answers
211 views

Guitar Hero III Bot

I made a Guitar Hero III bot for PC. I was able to beat the song "Through the Fire and Flames" on Expert with the bot which can you see here. If you watched the video, you can see that the bot misses ...
0
votes
0answers
34 views

Trying to implement cross-class functionality that needs a field to operate in C#

Crosspost from here, it was suggested that this is better place to pose my question. I'm implementing a series of classes in a game that all derive from one base class that references the scripting ...
8
votes
5answers
812 views

Largest Prime Factor (PE3) using OOP

I want to learn some C# syntax/paradigms (I'm more used to Java), and have been wanting to get a bit better at math as well, so I solved ProjectEuler3: Largest prime factor with the following small ...
4
votes
2answers
57 views

Initializing immutable objects with a nested builder

I need to initialize several parameters of an object but I also wanted to make it immutable. At the same time I don't want the constructor to take all several parameters because some of them are ...
1
vote
1answer
69 views

Choosing/creating/setting an NPC dialogue - follow-up

Initial post: Sequentially displaying a list of game objects This file creates a dialogue box, sets the chat history box too inactive. It finds which NPC dialogue to display creates the list and sets ...
9
votes
3answers
677 views

Binary search in C#

The challenge requires the program to receive data from the console and use binary search to find if a term is contained in a set of other terms. I've unit-tested the solution below, but according to ...
2
votes
3answers
49 views

Calculating the Collatz Conjecture

Today I read this thing about the Collatz Conjecture and wanted to try and write a program that calculates all the numbers. If you have any idea how the code could be shortened, please tell me. ...
3
votes
0answers
42 views

Handling of filters in c#

Let's say that i have a database which contain cheese. I love cheese. Depending on the request my server is getting (c# WebApi), i have to filter user data accordingly. Maybe the user wants to only ...
1
vote
1answer
72 views

Select query helper for nolock and no change tracking

I often need to switch connection strings and databases (dev/prod) and I need to be able to execute queries with the NOLOCK flag. For this purpose I create a few ...
2
votes
2answers
85 views

Concurrent bidirectional dictionary

I've been agonizing over this for an hour or two. I require a bidirectional dictionary that was thread safe. From what I understand about dictionaries, they're thread safe when being read from, but no ...
3
votes
1answer
35 views

CollectionViewSource Filter trigger for multiple controls

I have some markup: ...
-4
votes
0answers
20 views

sort viewmodel after id [closed]

I think I have a simple problem, I just can't seem to figure out... I have this ViewModel ...
5
votes
4answers
638 views

SharePoint CRUD class

I am writing an application where I have some objects like customer, supplier, product, etc. I have written a class for the object 'supplier' and wanted to ask if this is a good design. I have put in ...
3
votes
1answer
93 views

Sequentially displaying a list of game objects

A chat background is created and a text[0] is displayed with a button created under it. The created button iterates thru text[] ...
0
votes
0answers
55 views

Business rule interface: does this pattern already have a name? [migrated]

I'm working on an interface for implementing business rules; basically, moving a lot of logic out of Web API controllers and into a business rules library. I've done some research and came up with ...
1
vote
0answers
41 views

ORM class with private properties and public accessors for relationships [closed]

Notes before you proceed: I use Petapoco for DB Queries and Petapoco CRUD Wrapper for methods like Get(id), Save(), etc. But, ...
10
votes
1answer
112 views

ASP controller for tracking equipment

This was originally posted here. I'm hoping Code Review will be a little more helpful in giving me a concrete direction. I've been working on a project based off of this tutorial. Unfortunately, ...
3
votes
2answers
136 views

Connected components in an undirected graph in C#

My knowledge in graph theory is very limited. I have to look for elements in an (undirected) graph who are in the same connected component. The idea is simple. First, build the graph. Then, allocate ...
5
votes
4answers
101 views

Time difference

I'm using DateTime C#. I have an XML file with attribute HOUR, i.e: <MyXML> <LastTimeTaskRun>11:50</LastTimeTaskRun> </MyXML> And i ...
2
votes
0answers
45 views

AutoDictionary for object with a key property v2

I think I get it right now. This time I've implemented it with the IDictionary and added a few convenience methods. There is however one issue that without ...
5
votes
1answer
84 views

AutoDictionary for objects with a key property

The normal dictiory separates the key from the value... but what if the key is a part of the item it stores? It then forces you to enter the same things twice, once for the key and agian for the item. ...
11
votes
5answers
743 views

Removing n elements from array starting from index

This method removes n elements starting from a given index, from an array of a given type. If n is positive it removes elements forwards, if it is negative it removes them backwards (e.g. for an array ...
9
votes
4answers
2k views

BigInteger formatting for endless tower defense game

I am working on an endless tower defense game in Unity. To keep track of money, damage, hitpoints and stuff like that I will be using BigInteger, which can ...
2
votes
0answers
70 views

Reactive Properties for easy property binding

This is my attempt to write a data-bindable, platform independent property that doesn't require any literal strings. The basic idea is to basically have the same functionality as IObservable, but with ...
4
votes
2answers
81 views

On-line evaluation of mean and variance in C#

In various projects, I have to evaluate the mean and/or the variance of relatively large samples. I wrote the following, to help me evaluate these quantities with a constant footprint. Basically, it ...
4
votes
2answers
328 views

Generic binary tree in C#

This is a simple implementation of a generic binary tree that holds elements of type T. I was wondering if there was something that could be done better (especially in the EnumerateNodes methods). <...
1
vote
2answers
102 views

Simple Repository Pattern without ORM and Unit Tests

I'm trying to implement the repository pattern in the following manner: Interface: ...
4
votes
2answers
83 views

Spell and cooldown system for an Unity game

So I have doubts about my code and if it is any good. I have a parent class Spell: ...
1
vote
1answer
31 views

Performance of an OLX crawler

I'm learning concurrency and asynchronous programming in C#. For a better grasp on the matter I'm trying to create an OLX Crawler. My issue here is the performance: It takes roughly 159 minutes to ...
1
vote
1answer
109 views

Custom Exception.ToString() formatter

I find the default Exception.ToString() formattig very difficult to read especially if there are inner exceptions involved. I guess everyone knows how it looks: <...
3
votes
2answers
83 views

Genetic algorithm implementation

Is this the best way to implement a genetic algorithm framework? I'm just a student and wanted to know if I can improve the code that I have done. Some of the code I copied from the framework ...
7
votes
1answer
106 views

Active Directory Tool - WPF application to query active directory and display results

This is a Windows Presentation Foundation application that queries active directory and can display lists of users, users by group, groups, and users by manager (direct reports). It operates on ...
-1
votes
1answer
60 views

How can I optimize iterative algorithm purposed to distribute signal to Fourier series? [closed]

I want to show you an iterative algorithm to purposed to distribute signal to Fourier series. When I ran unit tests I gaven following results: - one iteration: 595 ms, failed; - ten iterations: 3 sec, ...
2
votes
2answers
83 views

Function to compare objects based on type enums

I'm looking for a better way to implement a huge CompareTo function that relies on an Enum to perform sorting. The data structure is essentially a flattened Multi Level Group. Any ideas and concept to ...
12
votes
5answers
771 views

Validating integer or string input

I'm at uni and working on an assignment in c# that takes some user input (from they keyboard via console). The input validation required: numbers must be within range (range will vary depending on ...
5
votes
2answers
76 views

Grouping rectangles horizontally and vertically

As you can see the below code for each method is that same, except for the properties it uses. For example X vs Y and ...