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

0
votes
0answers
3 views

RabbitMQ Consumer

I am playing with RabbitMQ and .NET and found myself duplicating the connection initialization logic in all of the consumers. Created the Consumer in order to ...
2
votes
0answers
11 views

Creating and combining rectangles based on a result of an edge detection

Context In an imageprocessing project of mine, I needed to do some edge detection and implemented the Theo Pavlidis algorithm which works quite well. A problem had been to get the next "good" ...
0
votes
0answers
10 views

Avoiding action class proliferation in my dialogue system

I'm running into an issue of class proliferation in my dialogue system. The system works fine as it is, but I just finished writing out a list of possible actions that could happen based on the ...
2
votes
2answers
75 views

Two functions to impose order on queries

I am writing a c# program to build generic sort algorithm on a request to a collection of data. The data needs to be sorted based on the supplied columns.I am using Entity framework and Expression ...
0
votes
0answers
27 views

Is there a better way to grab the previous 4 quarters?

I'm currently doing it in SQL and I'm curious if there is a way to slim down this code in SQL or in ASP.net MVC C# ...
4
votes
2answers
63 views

Linq refactoring

I have some code that asynchronously load some point in chart when user drag it. ...
0
votes
1answer
95 views

Processing selected and deselected elements

I think that this code is very bad because it does not agree with DRY principle. Can you advise me how to improve it? ...
0
votes
1answer
68 views

Event-based producer/consumer in C#

I want to create a production-ready producer/consumer that could help me avoid thread synchronization hell. Is this thread-safe? The main issue is to be safe with exceptions that can arrive. ...
3
votes
2answers
28 views

EncodingTranslatorStream - A stream object that translates character encoding

This class is a stream designed to perform character encoding translation. So you instantiate it, pass an input stream, and specify the input encoding and desired output encoding, so that when you ...
2
votes
1answer
51 views

Get Elapsed Time as Human Friendly String

In lieu with several other Facebook-esque concepts I am trying to replicate, this working code will take the span of time from a given date to now, and try to convert it into the most convenient ...
3
votes
1answer
48 views

Proper use of timer in windows service

I have following code to use timer (System.Timers.Timer) in windows service. The goal is that new time handler should not occur if previous one didn't finish its job. Here is how I achieve this: ...
3
votes
0answers
35 views

Facebook-esque User Search

I'm looking for some opinions on improvement/technique of code in C# calling to a Neo4j database to perform a multi-faceted query looking for users. My goals were to lookup by first/last name, phone ...
1
vote
0answers
23 views

ASP.NET View Model / Identity Model

I'm working in MVC5/WebAPI using ASP.NET Identity, with a custom storage provider for my UserStore, custom ApplicationUser ...
4
votes
0answers
40 views

External API calls from a C#.NET client

I have a simple c# mvc client that calls an external api..here is my attempt ...
0
votes
0answers
20 views

ASP GridView Calculated column [on hold]

I need to check your views on following. I have a grid which has a calculated column. The calculation is done using (Col A - col B) / SomeLabelAtTopofPage.Text ...
-2
votes
2answers
25 views

Moving cellcontentclick elsewhere c# [on hold]

I want to move the functionality from my cellcontentclick to be when a combobox's index changes. ...
4
votes
2answers
132 views

Script that parses the Chase.com page for my recent payments

I wrote this code earlier to parse Chase.com's online transactions page. It's written in WinForms. stepBtn is a button that starts this. ...
1
vote
2answers
42 views

MemoryQueueBufferStream

This stream class is designed to hold data only until it is read from the stream. As opposed to the MemoryStream which holds data until the stream is closed. It was written some time ago and was ...
5
votes
2answers
36 views

Return a rank for string of letters based on alphabetical permutations

So, first off, a little bit of unrelated information: I am preparing for a technical interview. I was reading this article, How to Prepare for (and Ace) the Technical Interview, by Rich Hein and I ...
4
votes
8answers
474 views

String reversal, capitalize vowels, lowercase consonants

This was a portion of a skills test given to me by a company. The task was to write a method that takes a string, reverses it, and sets the vowels as capitals and consonants to lowercase. I was also ...
0
votes
0answers
30 views

Simple wrapper to use IEnumerable as a producer in a producer-consumer pattern

I have a relatively simple problem: I have an IEnumerable<T>, which takes considerable time to yield each term. This is then used by another piece of code, ...
4
votes
1answer
20 views

Hashing a SecureString using Cryptography Next Generation

Goal: I needed to calculate the salted hash of a password, where the password is stored as a SecureString. There doesn't seem to be much .NET framework support for SecureString. In particular, none ...
3
votes
2answers
47 views

Manage Sessions within a Singleton

I am looking for advice if the below code is a good idea or not. If not, why? I am building a website which allows a user to purchase items. The user account and cart items will be stored in Session. ...
2
votes
3answers
285 views

String Calculator Kata Code in TDD style

I have done the following kata in TDD style and would appreciate it if someone could review my code and my tests. String Calculator Create a simple ...
4
votes
1answer
60 views

System.Drawing.Bitmap Wrapper Class

I have created two classes to help me work with images in C#. I decided to wrap the System.Drawing.Bitmap so I don't have to deal with different file formats (let ...
0
votes
0answers
34 views

Unit testing Socket communication with a race condition

I've developed a library that wraps TcpClient TcplListener objects into the concept of ...
-2
votes
0answers
15 views

Data Binding SQLIte to Listbox(containing three controls) Windows phone 8 [on hold]

Iam new to implementing SQLITE DB & windows phone 8 app development... Implemeted following startegy to retreive data to listbox which contains three other controls.. here ...
6
votes
2answers
196 views

EF lookups and enums

I have a lookup table "RequestTypes" that has the following data: ...
4
votes
6answers
118 views

Speech Synthesis to showcase how various voices sound with System.Speech.Synthesis

I was wondering if you would be willing to give me some suggestions on shortening this code. I feel as if the amount of if statements I have is a bit much. ...
4
votes
1answer
70 views

Daily Desktop Background

I've created a simple command-line program that downloads the Bing Image of the Day, then sets it as my desktop background. It is a console application, and closes immediately after setting my ...
7
votes
2answers
101 views

Is my implementation of FizzBuzz overkill?

I am doing FizzBuzz on a take home test (in Unity). I am sure this is just a competency check, but I went ahead and followed some coding conventions such as using constant fields, dependency ...
2
votes
1answer
45 views

Loading a Model from a Database

As you will see from the code below, I have a base model. ...
3
votes
1answer
51 views

Very simple asymmetric RSA encryption in C#

Based on this: asymmetric encryption in C# I added some more functionality to make it even easier to use (I combined the keySize and the ...
4
votes
2answers
107 views

Controls Edits of DataGridview in Winform

I want to refactor this code that is currently in a partial Form Class and deals with edits made on certain cells in a datagridview (in this case called dgvReplenish). I would like to refactor so ...
2
votes
1answer
41 views

An extension method to get the current user [closed]

I think that everyone is familiar with the concept of a context (such as HttpContext in ASP.NET) where you can put some shared ...
4
votes
1answer
36 views

ASP.net Identity admin reset user password

I have an application which uses ASP.net Identity as for its user authentication. I do not wish for users to reset their own password (for reasons which are not relevant here), so I have developed ...
7
votes
1answer
57 views

Improving Terrain Generation Time in C#

I am working on making my code run smoother, since I will be using it a lot in a game in development, but I am stumped. Is there any way I could make this run faster? Improvements to the terrain ...
2
votes
1answer
36 views

Checking for user permissions

The idea here is we have Roles, Permissions, and a table called PermissionRoles that connect the two. So a Permissions can be in many Roles, and many Permissions can have the same Role. So what the ...
4
votes
1answer
54 views

Saving a form to a database

I have a windows form application which uses a form for two different purposes. We use the form for both our handheld system and our in-house system. I would just like someone to review the code for ...
5
votes
4answers
530 views

Simple Binary Search Tree

At the moment I am learning algorithms and here I am trying to implement a simple binary search tree. I would like to know your suggestions on whether I am on the right track or not, and how this can ...
-2
votes
0answers
35 views

Is a single character name (T) preferred over canonical (Generic) when referring to generic types? [closed]

It's a de facto standard to call a generic type in a method call using T like in the example below (I'm saying de facto, because it's not a standard per se but quite commonly used like "hello world" ...
2
votes
2answers
73 views

Optimized ulong prime test using 6k+/-1 in parallel threads with C#

For primality testing of 64 bit ulong, I have optimized a very fast trial-by-division test using possible factors of the form 6k+/-1. For input numbers less than ...
4
votes
2answers
216 views

CheckChanged event readability

I have a CheckChanged method that I would like to improve as it takes a lot of space in my program and really hurts readability. The method prompts the user for ...
5
votes
3answers
66 views

Analyzing naming conventions

I just created a naming convention analyzer + code fix based on the Roslyn platform. The implemented naming conventions are the following: If you're interested in seeing all the test scenarios that ...
0
votes
1answer
30 views

Sieve32, a simple 32 bit sieve returning IEnumerable<uint> using C#

What a difference 1 bit makes! This very fast, simple sieve of Eratosthenes quickly finds 32 bit primes. It uses a memory efficient BitArray for odd numbers – but ...
1
vote
0answers
54 views

Retrieving Primary Key from Entity Framework entity

Entity Framework (version 6) generates classes based on your tables that look like this (where each property represents a field in the table): ...
4
votes
2answers
224 views

Database Update class using SQLCommand

I would like to have advice on this use of base class and derived class. This all works but is it a good way to achieve a SOLID class? ...
-1
votes
1answer
46 views

Generically calling an overloaded method [closed]

CreateInputParameter is an overloaded function with 6 type overloads, is it possible to simplify the following code or is this as good as it gets? I wish ...
5
votes
1answer
54 views

Checking the GridColumnType using a switch statement

I am trying to refactor a switch statement. I know that you can replace a switch with a ...
3
votes
1answer
41 views

Razor view to render simple scaffolding for complex type

After several attempts to follow my intuition that this code can be refactored to something more DRY, I keep hitting road blocks. Hoping someone can see a refactor that might get me going in a nicer ...