.NET is a software framework supporting a multi-language paradigm and supporting language interoperability. .NET applications are executed in a virtual machine (CLR) which provides a few important services: security, memory management and exception handling.

learn more… | top users | synonyms

1
vote
1answer
24 views

Shared access point

In my game, people connect to my server. The server creates a GamePeer per connection. GamePeer creates one ...
4
votes
1answer
32 views

Implementation of the FNV-1a hash algorithm for 128-, 256-, 512- and 1024-bit

A little over a year ago, I asked this question. Since then, I've implemented the larger bit variations and am looking for any and all feedback - performance is obviously key when talking about ...
-1
votes
0answers
20 views

.NET - LINQ: Using abbreviations [on hold]

When using LINQ. What is your approach to abbreviations? Is it OK to use abbreviations when you write LINQ? Alot of Microsoft's samples uses abbreviations but my personal experience tells me that ...
3
votes
0answers
46 views

Using Roslyn to find interfaces within a solution

The intent of the below code is to find all interfaces within a solution whose fully-qualified names match the given predicate. It seems to work, but as I am new to Roslyn I'm guessing there are ...
3
votes
1answer
43 views

.Net BouncyCastle - CSR and Private Key Generation

The purpose of this code is to generate the CSR and the Private Key. The scenario is that we have some clients for whom we run websites and for the SSL component we want to have a page on our site ...
-1
votes
0answers
19 views

efficiently retrieve records from a DB, using an existing structure

I'm currently building a MVC application with C#. The database has a User(Login.cs) table, though I also have my own User class (MyUser.cs), which contains some validation and a static method. The ...
-4
votes
3answers
89 views

Application search form

I have a search form in my application. When I search, it takes too much time to retrieve and display data, so I need to optimize this code. ...
5
votes
2answers
106 views

Using Linq syntax, how can I remove the select n+1 issue in this method?

I have the following code in a validation module. It works the way I want it to, but it has an obvious select n+1 problem. I would like to refactor this code to make a single call to the db to perform ...
8
votes
3answers
138 views

Collection that can be modified in a foreach

Sometimes you want to add/remove items from a collection inside of a foreach loop. Since this isn't possible, a common pattern is to add the items to a separate ...
4
votes
2answers
51 views

Generic object pool class using Spinlock/Monitor

I've written the following object pool class, and because this is my first encounter with synchronization primitives, I need reinsurance from an expert that this code is safe. I've tested it myself ...
3
votes
0answers
160 views

Is this pattern of Task queueing acceptable?

The AsyncWorkerQueue class uses TPL Data Flow and Rx to async process and cancel work in a queue. It takes in a worker factory (Func) and executes it when its turn (or not if its scheduled to be ...
2
votes
1answer
49 views

Go through every pixel of an image and then dispose of it

I'm a little confused as to whether implementing the Dispose method serves a purpose in this code. It never gets referenced by any other class in my project, so ...
1
vote
1answer
76 views

Thread Safe Objects in CSharp - ConcurrentDictionary

I'm using ConcurrentDictionary to hold the records.. I'm reading files from the local system in parallel, to speed up the process. Sample 1: ...
1
vote
3answers
51 views

Initializing object by settings implemented as a class [closed]

Here is the story. We have the BankTerminalSettings class. It has many properties: ...
5
votes
2answers
81 views

Optimizing this method (HashSet.RemoveWhere performance issue)

I have the following method: ...
8
votes
4answers
116 views

Multiple 'using' statements in method implementation

I'm learning WebAPI framework for ASP.NET and C#. Is the following way of handling incoming data correct? ...
0
votes
1answer
83 views

XML document parser with XPath

Here is my simple implementation on XML parser for XML which I received from a server response. Also I've tried to use XmlPathDocument but failed to get child ...
4
votes
2answers
152 views

TCP chat application with both server and client logic in same application

Here is my simple chat program. I'm wondering whether it has an acceptable design (both object oriented design and network design). If you want to run it, I can provide the solution folder. ...
3
votes
1answer
64 views

Using list of tasks to obtain and cache data

I develop Windows Phone App with Prism framework (MVVM). I use data caching. To get data I use proxy service. Proxy service creates two ...
1
vote
2answers
64 views

Setting every element in an array to a given value

Given the length of an array and a char, I would like to replace every element in a char array with that given char. Using a ...
6
votes
1answer
93 views

A super string cleaner

I need a method that clean up a string considering these few rules: Remove or not Spaces Remove or not Special Chars Remove or not Numbers Descaptalize or not the string (this is don't really needed ...
7
votes
2answers
339 views

Which option is better for readability when dealing with blank strings?

I'm working off a specification that says a bunch of fields within a record (one record being one line) must be blank. For example, it says that chars 6-14 must be blank. I am building a class ...
6
votes
2answers
436 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 ...
0
votes
4answers
72 views

Remove extra spaces from a string without using Regex or any internal library methods

The objective is to remove extra spaces from the below string: " Today it is going to rain. " so it looks like below ...
2
votes
1answer
40 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 ...
6
votes
1answer
128 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 ...
2
votes
1answer
64 views

A thread-safe initialization guard

I have written a type with the following public API: ...
3
votes
2answers
80 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 ...
4
votes
2answers
182 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 ...
4
votes
1answer
62 views

Executing a list of tasks from a database

I have a list of tasks I get from my database (as strings) and then execute. However I'm uncertain on how to implement this correctly. Currently I have implemented this in the following way: ...
1
vote
1answer
130 views

IRepository Pattern - Interface Segregation Principle

I have an IRepository class that I use a lot. But I noticed that for many of my repositories I do not implement most of the methods. Also, I usually don't have a ...
2
votes
2answers
138 views

Timecode class design

I've created a Timecode class. The "timecode" that I'm trying to represent is a timecode that is used in video editing quite often, and is seen displayed in the ...
10
votes
2answers
398 views

Reusable Unit Of Work Interface / Factory

Given my IUnitOfWork interface using System; public interface IUnitOfWork : IDisposable { void Commit(); } I then ...
5
votes
1answer
161 views

Regex for matching a US phone number

I have written my first regex: ...
3
votes
3answers
89 views

Zero pad function trim extra leading zeros

Here is a zero pad function I have: ...
2
votes
5answers
199 views

IIF shortern to one datarow .Net

Is it possible to shorten the Isnull checking? It would be great to shorten this code and only have to put the datarow once. This code imports data details (usually there would be more .x = ...
3
votes
0answers
46 views

Calculate compilation time from AssemblyVersion attribute

In my program, I display the compilation time which is calculated from the AssemblyVersion attribute. The attribute is set to automatically generate a version ...
1
vote
1answer
336 views

Adapting C# 2.0 event code for C# 5.0

I came across this excellent post on delegates and event and tried to adapt it to C# 5.0L ...
1
vote
1answer
83 views
2
votes
2answers
73 views

Avoid Split to reduce memory press (on servers)

I have a Component that is used for all Active Directory queries. The function below is used heavily perhaps even milions of times each day. Performance is a feature! It's used on servers and I ...
3
votes
1answer
55 views

Conversion Helper with support for enumerations and Nullable<T> - The Remix

I recently wrote this code as a more versatile stand-in for Convert.ChangeType. I very recently posted an earlier version, for which I received some good feedback. I've incorporated that feedback and ...
3
votes
3answers
110 views

LINQ foreach - error handling and general improvement

I'm looking for two kinds of feedback: Is there a better way of doing what I'm attempting to do? Any obvious weaknesses that could potentially cause problems? The code in question (I've broken it ...
2
votes
1answer
114 views

Checking if a directory exists in FTP without relying on exception handling?

I've written a method to check if a directory already exists on an FTP server. The only way I could see to make this work was to return a different result from the method if an exception is thrown - ...
5
votes
3answers
125 views

Conversion helper with support for enumerations and Nullable<T>

I recently wrote this code as a more versatile stand-in for Convert.ChangeType. I have a nagging feeling that there's something I might be overlooking, or that ...
3
votes
1answer
70 views

Event Subscriber with Parallelism

I am trying to exploit asynchronism for parallelism. This is my first attempt at a parallel event subscriber. In your expert opinions, is this a valid approach? ...
-4
votes
1answer
66 views

Declaring the reference of an object within a for loop [closed]

Please let me know which approach is better and why. Is it better to initialize the variable outside of the loop, or inside? Case 1: ...
3
votes
1answer
70 views

Invoking only the last registered event handler

We are building a game and we have a dialog system. Dialogs may open and stack on top of one another. When every dialog opens, it registers itself to handle the BackButtonPressed event: ...
14
votes
9answers
670 views

How can I refactor to avoid repetition finding the index of strings in a list?

I have a list of strings where I want to find the index of a first- and second-choice video compressor. Logic: If the first choice is available, return its index. If not, and the second choice is ...
2
votes
2answers
164 views

Streamreader file.Readline properly closing the stream

Is this OK? (.Net 4.5) ...
7
votes
1answer
584 views

Math expression parser in C#

EDIT: Added refactored version 2.0 to the end! I have a parser that is supposed to take a string similar to a math expression and return a Tuple of: An array of strings where each string ...