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

7
votes
2answers
220 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 ...
6
votes
4answers
115 views

Nested object to hierarchical object list

I have a C# type to generate Layer SubLayer: ...
3
votes
3answers
281 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 ...
-4
votes
0answers
25 views

wpf ugly event dictionary [on hold]

I have a WPF application with two viewmodels(AViewModel,BViewModel). I think that main problem is that ...
0
votes
1answer
25 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
51 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
66 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
54 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
112 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
87 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
77 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
53 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
123 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
51 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
64 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
17 views

Code for Accessing a function from Unmanaged dll [on hold]

The following code accesses a function from an unmanaged dll. ...
6
votes
1answer
55 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
43 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
550 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
246 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
35 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
41 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 ...
-4
votes
0answers
60 views

Repository pattern with interface based injection [closed]

I have been using option 2 below to refactor some legacy code. However, I have seen a lot of people doing injection using option 1. Can someone help me review the code below and let me know if there ...
-3
votes
0answers
41 views

Personal messages structure [closed]

This is the PM markup: The left bar is the list of users (with whom you started the conversation) and the right bar is the PM feed. User Entity: ...
3
votes
1answer
51 views

Simple Vector2 structures (and interface)

I built a couple Vector2 structures (Vector2 and Vector2F) for use with a particular ...
7
votes
1answer
87 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
52 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
533 views

Percentage calculation

What would be the best way to refactor following methods? ...
4
votes
2answers
199 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
284 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
75 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
99 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
373 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
62 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
84 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 ...
3
votes
2answers
66 views

Small Launcher Application

I have just somewhat completed a program, and was wondering what I could do to improve readability, and design as some functions seems to be rather large and an eye-sore. ...
5
votes
2answers
119 views

A possibly-terrible alternative to conditionals full of null checks

I am always super annoyed when I have to write a bunch of if statements whenever I have to traverse an object graph of possibly null objects. As there is not yet a ...
0
votes
0answers
85 views

Generic method to pass lambda expressions performed on DTO's to Entity Framework

The following are generic methods that I use to perform lambda queries on DTO objects. The main method applies the expression to entities and returns DTO objects mapped from the entities (entities ...
5
votes
1answer
38 views

Salsa20 stream cipher implementation

I have implemented the Salsa20 stream cipher as an ICryptoTransform. It runs fairly fast and has successfully encrypted and decrypted all of my tests. I would ...
6
votes
3answers
338 views

Finding the postion of a substring in a string

I am given two strings and return the position if in the larger string the smaller string is found. If not I am returning -1 for position. Any suggestions for improving my code. ...
4
votes
2answers
71 views

Two sum algorithm variant

I need to compute the number of target values \$t\$ in the range: \$-10000 \le t \le 10000\$ (inclusive) such that there are distinct numbers \$x, y\$ in the input file that satisfy \$t= x+y\$. I have ...
6
votes
1answer
45 views

Getting all public constants from the main and nested classes

I wrote this recursive function to get all constants from a class and its subclasses. Can it be simplified? ...
1
vote
2answers
28 views

Cameras and ITrackableObjects

The purpose of these two classes (and hence why I am including them together) is to allow you to create a Camera, that indicates a "render zone", and track an ...
6
votes
1answer
90 views

Do you want to be a super (voxel) hero?

I have implemented an upgrades system in my Unity3d game, and I am pretty sure that I am not doing things in an optimal way. Any advice regarding best practices would be much appreciated. The idea is ...
7
votes
3answers
216 views

XNA KeyboardStateManager

This class allows for easy management of the KeyboardState of an XNA game. It provides a simple, easy-to-use API for interacting with the Keyboard and getting ...
9
votes
3answers
908 views

AES implementation

We are using an outdated 3DES algorithm for encryption and I have been tasked with writing a new implementation using AES with a 128bit shared secret. I would like to know if there are any security ...
0
votes
1answer
54 views

WPF filling a DataGrid

I'm creating a WPF application with a DataGrid. I'd like some advice on the code I've written: ...
18
votes
5answers
1k views

Console window to debug Windows Applications

Since I was having some difficulties to debug the next step for Scrolly - A (very) simple infinite mouse "scroll", I've decided to make a console-like class that allows to add messages to it. This ...