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
16 views

Validator part 2

This is a follow up to: Validating individual properties and whole items I have a custom class I've written which allows me to validate individual properties of items, without firing validation ...
5
votes
0answers
18 views

Rubberduck VBA Parser, Episode V: The ANTLR Strikes Back

I changed my mind. I don't want to implement 200-some Node classes. Instead, I'll be working directly with the ANTLR generated classes, to implement the Rubberduck ...
3
votes
0answers
10 views

VSTO Write Dictionary To Range Extension Method

I was hoping to receive some criticism on this block of code. I wrote it to write the contents of a dictionary to excel range in VSTO. It works well. I am interested to see how people could improve ...
1
vote
0answers
7 views

IRC Server Response Parser for IRC Client

I wrote a parser for the IRC RFC 2812 spec and would like input on my use of the strategy pattern for this. I created an IrcMessage class that is responsible for ...
7
votes
2answers
111 views

Build List from unshared items from two other Lists

Ultimately, my goal is to take two lists and then generate a third consisting of items that the first two lists do NOT share. I am able to get the results I want using two ...
1
vote
0answers
11 views

Batcher using Microsoft.Tpl.Dataflow

What do you think? In particular, I'm not sure about my exception handling approach to raise errors when posting objects; but I couldn't come up with anything better. ...
4
votes
1answer
28 views

Showing items and categories after clicking on a subcategory

How can I speed up my app? It's very slow if I click on a button and open a new page. All data in time is local. I'm not sure if the problem is in my code or xamarinu. ...
4
votes
2answers
39 views

Best way to identify a computer in LAN C#

I have a web application to manage computers. Every registered computer is locally querying the latest information and updates the database with it in a 10 minute cycle. But the computer is only ...
8
votes
2answers
399 views

Customized Exception

I am building my "base exception to end all base exceptions" class in C# and was looking for some opinions on my implementations so far. Ideally my usage of integrated Rethrow, Throw, and ThrowFatal ...
7
votes
2answers
57 views

Go Back to Previous Item

I have a Back function, and it is growing. I also think this is terrible, but I don't seem to get how it can be improved: ...
5
votes
1answer
63 views

Beat detection algorithm implementation

What is the quality of the code I've written? Is it easy to read or is it a low-quality piece of code? Also, is there any way I can improve the algorithm itself (beside changing C parameters)? ...
2
votes
2answers
35 views

Finding the shortest path through a 2d space with a display

I decided to implement most of the reddit Daily Programmer space probe challenge. My program creates a 2D space that have asteroids and gravity wells distributed (the percentage of gravity wells and ...
9
votes
2answers
101 views

Of Procedures and Variables: never enough nodes

Building on my ANTLR tree listener, I'm now starting to see how the whole thing is coming together. As I proceed to implement the numerous Node classes I'm going ...
7
votes
1answer
42 views

Unit test for Unique Position Point

Here is one of my msTest Unit Tests and possibly one of the worst "looking" tests. ...
6
votes
2answers
141 views

C# AES Encryption

I've been researching AES encryption a bit over the past several days. The official (MSDN) examples I've seen are encrypting and decrypting using the same AES instance. They don't go in to what to do ...
4
votes
1answer
80 views

Throttling REST requests in C#

I'm rather new to C#, and found relevant subclassing examples surprisingly hard to come by. I've whipped up this class that appears to work, but am pretty sure this is not optimal: ...
3
votes
2answers
46 views

Searching for nodes in a huge tree

This is supposed to search for a node in a huge Treeview. The node could be found in many places. In other words there may be many nodes and the resulting tree should be expanded depending on where ...
12
votes
1answer
104 views

Rubberduck VBA Parser, Episode IV: A New Hope

My home-made wannabe-a-parser was wet behind the ears, so I started seriously looking into more mature alternatives, and ended up adding a dependency to the ANTLR lexer/parser generator tool, and ...
1
vote
2answers
94 views

Traverse all switch branches without goto

I'm wondering wether there is a way to walk through every branch of this switch without using goto ...
2
votes
1answer
46 views

Validating individual properties and whole items

I have a custom class I've written which allows me to validate individual properties of items, without firing validation errors on other properties. This allows me to individually validate what my ...
4
votes
1answer
45 views

Creating a TCP Listener and receiving data

I am very new to network programming and I'm thinking I have probably misconstrued the creation of an appropriate TCP listener. The code I have below works perfectly, but I have a feeling it's a "hack ...
8
votes
3answers
323 views

Get values between two dates

I have a search form where users can enter ValidFrom and ValidTo dates, There are three conditions: ...
2
votes
1answer
39 views

Creating automatic resizing of subelements in WPF

I currently have this code: ...
2
votes
1answer
77 views

Single Responsibility + Entity Framework

I still feel like I struggle to grasp some concepts of SOLID principles at times, and am hoping for some clarification here. The following classes are entities in an Entity Framework project. ...
4
votes
1answer
57 views

From event handler to command: on my way to MVVM

I have a WPF C# application that I want to move to a MVVM pattern. My first step is to remove the button click handlers from the code behind of the UI. I've found some examples online and then ...
8
votes
3answers
558 views

Shoot The Messenger Part 4

This is a follow up of: Messenger supporting notifications and requests Shoot the Messenger pt. 2 Shoot the Messenger Part 3 I've written a lightweight (I think) class that acts as a messenger ...
8
votes
2answers
60 views

Lvl2 upgradeable attributes

This is a follow up to: Lvl 1 upgradeable attributes From before: I've built the groundwork for an attributes (as in Strength, Intelligence, not as in ...
8
votes
1answer
76 views

Reading Values From Enviromental Monitor XML Feed

I have written the below code to handle accessing and parsing the data presented in XML format from our server room environmental monitor. The plan is to call this class from a controller/view ...
10
votes
3answers
209 views

Simple Generic output for Deserializer

Lately I have been learning about serialization so I decided to write a little helper class for my application to make it easy to use this feature in multiple places. I actually mixed some generics in ...
2
votes
1answer
32 views

Detecting the attachment of a DataContext

In our application the views and the viewmodels are created in parallel to increase the performance and when the viewmodel is created it is attached to the datacontext. While there is no datacontext ...
3
votes
2answers
59 views

Is this a thread-safe implementation of background bitmap generation?

For a game implementation, I have a very large overview map with multiple layers (namely base-map / units / highlight & info / fov-shading) of which the first is CPU-intensive to generate. I have ...
12
votes
2answers
467 views

Reverse a sentence quickly without pointers

I am trying to reverse a sentence contained in a string and return a string in the quickest way possible using the least amount of memory. Also I don't want to use any unsafe code, so no pointers are ...
4
votes
2answers
113 views

C# static class holding list of member class instances

I was wondering if such a design was a bad idea in C#. Here I have a static class EventLog which holds a list of instances of ...
6
votes
1answer
108 views

RoundStack Implementation

I just recently made an attempt at implementing what I have been led to understand is called a RoundStack, simply meaning contrary to .NET Stack's default behavior ...
-4
votes
0answers
19 views

Way to increase the value of entries in lists? [closed]

I have written a code where I'm rounding decimals to whole numbers and add them to a list. The program then checks the sum of those numbers against the previous sum of those numbers (before rounding). ...
7
votes
0answers
61 views

C# SHA512 Memory Issue

I need an implementation of PBKDF2 in C#. There is already a class Rfc2898DeriveBytes, but it uses SHA1, and I need SHA512. The problem that I faced with during ...
6
votes
1answer
43 views

Throttling commands

I have a scenario where my BaseRepository gets a lot of commands in a short time period. At other moments, this doesn't happen. What I want to achieve is to throttle these commands. I.e., when a ...
1
vote
1answer
57 views

Dependency Injection With Unity in MVC 5 without repository and unit of work

I want to use dependency injection with Unity in my application. I am not following repository pattern and unit-of-work (and don't want to). I also have ViewModel in my controller action method. ...
2
votes
1answer
43 views

A thread-safe initialization guard

I have written a type with the following public API: ...
3
votes
2answers
125 views

Uppercase the initial char of every string in a list

My problem is that I have a sequence, potentially infinite, of strings. Let's suppose it to be {"Mickey Mouse", "Bugs Bunny", "Winnie the Pooh"} I have to make ...
4
votes
2answers
252 views

Smartly encrypting strings

I am trying to encrypt the input string using the following rule: 1st Character of string will be increment by 4 ( a will become e ) 2nd Character of string will be increment by 1 ( a will become b ...
3
votes
2answers
83 views

Check if array A contains all elements of array B and vice versa irrespective of order

I am trying to check if an Array A contains all the elements of Array B and similarly ...
2
votes
1answer
48 views

Design patterns: choosing the right handler depending on data type

Suppose we have an application which process packets from somewhere. We should choose right handler for the packet depending on packet type and also we know that it might be necessary to change ...
6
votes
3answers
134 views

Classify values depending on predicates

I've to do a generic method Classify<T> that, given a sequence of elements of type T and an arbitrary number of ...
8
votes
5answers
826 views

Assembling a user agent descriptor, implemented using StringBuilder vs String

I think performance won't be a big issue here as the concatenation only happens once (2-3 at worse because of multiple threads). Out of the two methods, which one would you prefer, in terms of ...
3
votes
2answers
71 views

Communicating messages to objects

In my MUD game engine, I built a messaging api that allows objects to subscribe to concrete implementations of an IMessage interface. Is there anything glaringly ...
5
votes
1answer
48 views

Handle Settings in Windows App

So, I fixed my problem with a public ViewModel for my MainPage like this: MainPage.xaml.cs: ...
3
votes
3answers
105 views

SQLite insert code optimization

I just started working with SQLite in C# to test various features of an application. In building my first SQLite example I wanted to insert a large csv into a table (Person) with two columns, A and B. ...
4
votes
1answer
55 views

Class for easier to read IProgress<Class> handling

The recommended way to report something as "progress" back from a async function is to use IProgress<Type> or ...
4
votes
2answers
100 views

Query results with many to many and some parameters using Entity Framework in a more efficiënt way

I've created a working query in Entity Framework and I'm curious if there's a better way to do this. Since there's a lot of field on my models, I will only publish the relevant ones here. My Models ...