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
2answers
137 views

An AES Cryptography Wrapper

I built this wrapper over the System.Security.Cryptography.Aes encryption/decryption so that one need only instance the class and call the appropriate methods. This makes it much simpler to work with ...
2
votes
0answers
27 views

Counting email addresses with different status

I want to count email addresses with different status. I use ASP.NET MVC and this query is supposed to ran every 5 minutes on these tables, which every table is on different .ndf files. About 5 ...
0
votes
0answers
21 views

Recursive Search Binary Tree C# [on hold]

I am trying to find out if this program can check if a binary tree is BST or not, ...
3
votes
3answers
50 views

2D matrices addition

I have a 2 dimension matrix : ...
8
votes
3answers
466 views

Tic Tac Toe game in C#

I wanted to get into C#, so I tried making a simple game. My first language was Java, so it was pretty easy to get the hang of C#. I know that there are multiple other posts of tic tac toe games, ...
3
votes
3answers
521 views

Generating a URL

I have a function that generates a URL using a stringbuilder: ...
1
vote
3answers
70 views

WCF service and database

I have a WCF service that work with databse. The service should handle incoming message and store messagId into database. Please suggest me how can I improve it? ...
4
votes
1answer
60 views

Combating magic strings in a web application

I'm on a quest to combat all the magic strings which tends to pile up in an ASP.NET MVC application. All reviews will be highly appreciate but please note that: Some of the classes contains more ...
1
vote
1answer
25 views

Dynamic CSV Formatter

I made a dynamic CSV formatter as a personal challenge after having to hardcode a behavior to convert some data to CSV earlier. You input any List that contains supported types as properties (all ...
0
votes
1answer
45 views

Dictionary GetValueOrDefault

I'm pretty sure there's no better way to do this but I thought a consensus on here might be nice. Let me know what you think. ...
0
votes
0answers
16 views

Unit tests for a repository with the help of AutoFixture

I find it hard to do a test for a repository and very time consuming. Things I think about when creating unit tests for a repository: Should I skip creating unit test for them? Should I create an in ...
0
votes
0answers
24 views

Printing job task

Now I have task very similar to this: Job is a group of print items. For example, a job can be a run of business cards, envelopes, and letterhead together. Some items qualify as being ...
4
votes
2answers
305 views

Wrapping tuples to be used as keys in a Dictionary

I'm currently working on a project where I have to map some objects to several properties. Basically I need a Dictionary with Tuples as keys and instances of MyClass as values. As using tuples can ...
4
votes
6answers
856 views

Switching on hardware ports

I have the following function for turning on some ports on a piece of hardware: ...
1
vote
1answer
38 views

Change implementation from getting json from file to get it from API

I used to get a json file with some configuration settings from the file system, using this class ...
0
votes
0answers
8 views

The granularity level to repeat code: should downloading, unzipping etc. be handled by separate classes? [migrated]

I make extensive use of DI, but I wonder, where is the 'granurality' limit, when some set of functionality should be separated to a class - lets take an example: ...
8
votes
1answer
308 views

SalesTax problem (C# version)

One year ago I published an F# solution of the same task and there is an old C# solution. But I think it's a simple task and require a simple solution. What do you think? ...
4
votes
6answers
128 views

Centering a line of text

I need a procedure that "centers" a string inside a string that is consecutive characters of a fixed length. For instance, ...
-2
votes
0answers
37 views

Standard Dieviation code, how to do this using generics? [on hold]

I have been reading around a lot about generics and I find it useful when dealing with the repository pattern and patterns in general. But to date most of my code using generics has only been working ...
1
vote
2answers
101 views

Running tasks in parallel

I've just started writing asynchronous methods for the first time having watched some tutorials. I have a method where I run two tasks in parallel (...
1
vote
1answer
34 views

Optimise MSSQL Connection .NET Helper Library

I recently posted my old .NET MSSQL Wrapper to be code reviewed: .NET MSSQL Wrapper I had some good feedback and based on that, I was able to re-factor it quite a bit and ended up with the following ...
0
votes
1answer
41 views

Client for many similar kinds of REST requests

I have a class that makes calls to a Web API (Using RestSharp), which works fine but the code is super ugly. What would be the best way to refactor it? I thought of just doing a Facade pattern so all ...
4
votes
1answer
118 views

Is your source code “pristine”?

This was brought about by this codegolf question. Problem A program is said to be pristine if it is: A working program (No errors). The program will produce errors by removing any contiguous ...
-2
votes
0answers
29 views

Implementing Work Steal in multiple producer and consumer threads scenario in C# [on hold]

Kindly guide me the best and fastest efficient way to handle my below business scenario :-- I have to read pending records from one table present in 9 different database (table name and structure is ...
1
vote
0answers
23 views

Generic methods for serializing and deserialzing xml files using streams followup

Recently I asked this question: Generic methods for serializing and deserialzing xml files using streams However it has come to my attention that this gives me an (harmless) exception when trying to ...
3
votes
2answers
50 views

Extracting an XML config file from ZIP file and parsing it

I am currently working with an app that should load various info on a very specific zip file which contains the XML config file, using the DotNetZip library on C#, here's the code: ...
3
votes
2answers
194 views

Using EqualityComparer to find contained value

While searching for a method in HashSet which allows me to actually find an object in \$O(1)\$ (not just Contains, I need the ...
5
votes
3answers
309 views

Fetching, adding, and viewing games

This is a simple application that will eventually manage certain files for video games. For now, I'm only posting code that handles fetching, adding, and viewing games. I'm trying to keep things ...
3
votes
3answers
113 views

Converting a 12 hour time string to a 24 hour time string

Input - Standard input - HH:MM:SS[AM|PM] format. Examples: 12:00:00AM 12:00:00PM 01:00:10AM 01:00:10PM The program reads one line per instance. Output - military format (24 hour format): ...
3
votes
1answer
93 views

.NET MSSQL Wrapper

Back in late 2012, I wrote the following C# .NET MSSQL Wrapper, which offered the following operations: ExecuteScalar (for selecting single field from a row) ...
3
votes
1answer
76 views

Compress numbers in a string array (#3, #1, #2, #4) to range (#1:#4)

This function takes a string array, {"foo", "#123", "#124", "bar", "#125", "#126"} makes a new array with the numbers converted to a range: ...
1
vote
1answer
55 views

Convert numbers in a string array (#3, #1, #2, #4) to range (#1:#4)

Updated question: Compress numbers in a string array (#3, #1, #2, #4) to range (#1:#4) This function takes a string array, ...
1
vote
2answers
42 views

Random integer range with exceptions

I have to generate a random number from a range with exceptions held in a bool array, is there a way to do it without a loop depending on probability? There is also a potential infinite loop here if ...
-4
votes
0answers
17 views

Saving user information on exit in C# [closed]

Ok so I made a console application that stores data into arrays so I can log test scores but I need it to save on exiting the program. I want to be able to see the scores I entered when I reopen the ...
7
votes
1answer
176 views

Async Yield and continue on TaskPool

Using await task.ConfigureAwait(false) is a standard best practice for indicating to the compiler that the continuation does not need to be run on the current ...
1
vote
2answers
61 views

Adding new articles

Following is a working program to add new articles. The only thing I want is to check if there is any way to write it in a better way, or if the architecture is good as it is. Maybe I did not have to ...
-2
votes
0answers
25 views

Sending a message from client to server and back again

I have a client, middleware and a server in three Windows Form Applications. I can send a message from the client to the server via middleware but I need that message to come straight back from the ...
1
vote
0answers
18 views

Storing object converters, data sources, loading and updating configurations

I have a static class Configuration holding two collections: one for object converters an the other one for data sources. When I load a configuration from either ...
0
votes
0answers
48 views

lz77 is slow operating on byte arrays

I ported a lz77 implementation from java, changed it from operating on strings to bytes and improved its performance following the advices of this question. Testing the performance, I found that ...
1
vote
0answers
28 views

Safely aborting thrid-party code using TPL

I'm using some third-party libraries in my project. Once in a while the code in these libraries freaks out and produces infinite loops and other nasty things. My goal is to write a wrapper that allows ...
3
votes
0answers
26 views

WPF canvas drawing very slow

I am building a map editor to easily create 2d levels. To visualize how my level looks like I am using a canvas. On this canvas I can select which block is filled with a certain type ( like solid ). I ...
4
votes
3answers
143 views

Cipher decryption and encryption

I'm brand new to C# and I've started to make a cipher decryption program. The code works and runs fine, apart from the odd exception. I'm just looking for ways to improve my code and make more ...
2
votes
2answers
66 views

Index a document and perform analyses on its term vector

I have the following scenario: I create a lucene document from a potentially very large text. Apart from indexing the text, I perform some analysis on the document for which I need the document's term ...
1
vote
2answers
63 views

Validating users with Roles

I am using the following to validate my user which works but i wish to incoperate roles so I used the reg iis to add the standard tables aspnet_UsersInRoles. What I basically want is the ability to ...
0
votes
1answer
108 views

Static thread safe configuration class

I wrote this class. I would be very interested in your feedback how much thread safe this class is. I know users of this class must still use some kind of synchronization when using this class, but I ...
1
vote
0answers
37 views

Using the ConcurrentBag as an object pool for an ASP.NET application

Is there anything wrong with this implementation of an object pool that will be called from an ASP.NET application? The object I want to pool has extremely expensive initialization, so currently I ...
5
votes
2answers
51 views

Displaying a new image document in Picturebox

I'm using WinForms and have a picturebox in my form. This program looks in "C:\image\" directory to find a specified image document, in my case a tif file. There is always only one picture in ...
-4
votes
0answers
18 views

Code EF 5 causing null reference [closed]

For some reason im getting null execptions on my columns im just wanting to no is my code effience or is their a better way of handling this with MEF and entity state Used on page load to load a ...
5
votes
2answers
111 views
+50

Links controller in MVC N-layer architecture

I have a common issue that I face in my applications (because I don't know any better) and I want to improve. This is my usual structure: Project.UI (MVC Project) Project.BLL (Class Lib) ...