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

Sieve of Eratosthenes in C#

Just because I've never written a real Sieve of Eratosthenes, I decided I should probably write one just to make sure I know what it is. I'd like (constructive) criticism on best practices, potential ...
1
vote
1answer
17 views

Writing a testable standalone DLL without overcomplicating it

I've decided to challenge myself by writing a test standalone DLL with the objective of making all of its publicly-exposed objects able to be as intuitive and as simple-to-use as possible. I've ...
3
votes
1answer
25 views

AsyncTcpClient (Asynchronous TcpClient)

I've been doing network programming using C#'s TcpClient for several years. The code below is an asynchronous wrapper for ...
2
votes
1answer
96 views

Indexed Properties in C#

I was challenged to implement a mechanmism to support indexed properties in a class structure. I wanted to avoid the need to implement an abstract property indexer class every time you want to ...
-2
votes
0answers
16 views

C# Fouier Series Calculator, q is not calculated, only shows a zero [on hold]

namespace Tutorial_3_3 { public partial class Form1 : Form { public Double x1, x2, t1, t2, k, a, q; public Form1() { InitializeComponent(); } ...
0
votes
1answer
32 views

Network Send and Reply

I have developed a TCP listener to receive messages from a client machine, take that string and put it in a db, then send back a response with some data relating to that string. First attempt at a tcp ...
2
votes
1answer
29 views

SQL Dependency with Broker

I have written a windows service for one of our local servers. This service works like a gem on my local machine, does what it's supposed to (ACCP to exchange db data), but I'm not overly familiar ...
4
votes
2answers
39 views

High udpclient CPU use

I have a bunch of different ports I want to listen on and the iterate over the available data to send to a Dataflow pipeline. In total I'm listening on 14 ports. I'm looking for any advice on how to ...
0
votes
1answer
42 views

Wrapper classes for objects returned by 3rd party APIs

I am building a WPF application which uses a third party library to fetch objects which I want to allow the user to interact with. The objects are returned as interface types. Am I right in thinking ...
2
votes
1answer
50 views

Enums for measurement units, with possible circular dependency

I have some enums that define measurement information, such as volume, mass, distance etc... They are defined as such: ...
-4
votes
0answers
28 views

can this be improved? [on hold]

...
2
votes
1answer
45 views

Querying a database with Dapper

In the current project that I am working on, we are using dapper to query the database and sometime when mapping from dynamic types to concrete types we end up with a messy block of code. I created a ...
3
votes
2answers
38 views

Eager load additional data about some instructors

Below is a snippet of code of a little practice project. I am still pretty new to EF and I was wondering if there is a way to write the below statement so that all required data is eager loaded since ...
3
votes
1answer
53 views

Simple streaming parser to extract columns

In reply to previous question I rewrote ColumnReader and would like more suggestions ...
2
votes
3answers
140 views

ADT for a TVM calculator

I wanted to get some criticism for the below ADT. This is just a basic ADT that will be fed into a TVM calculator. Main purpose is to have it initialized and correct for input errors. Full ...
2
votes
1answer
26 views

Using self-hosted OWIN

I have implemented the following in order to handle JS XHR requests coming from HTML pages. Is there a better way to do this with OWIN? ...
3
votes
1answer
68 views

Generating a non binary tree structure

I am writing a method to create a folder tree. I am getting the data from a database and creating the list of nodes. Is there a way to get the method to execute quicker? Perhaps using parallel task ...
2
votes
1answer
120 views

Simple streaming parser to extract lines

It is meant to be given strings over time and output all NewLine delimited substrings. The ColumnReader is meant to be a solution for ...
0
votes
0answers
15 views

Completed WorkItem List population [on hold]

I have a program where we schedule work items in a queue and process them in background thread one-by-one and load completed work item into a list. Below is code to schedule work item. ...
8
votes
1answer
60 views

Inspector Rubberduck - Take Two

Release 1.1 of Rubberduck only had a handful of implemented code inspections, more as a proof of concept than anything else. For release 1.2, we now have 19 implementations of our ...
4
votes
3answers
415 views

Is it ok to use Thread.Sleep and Thread.Interrupt for pausing and resuming Thread like this?

I need to observe a ConcurrentQueue, but to minimize the resources I want to pause the Thread if the Queue is empty and resume it from another Thread if there is a ...
3
votes
1answer
82 views

Harry Potter books with discounts kata

I have implemented a solution to the Potter Kata. Basically, there are 5 different (types of) books, and the buyer gets a discount depending on how many different books he has bought. Multiple ...
1
vote
1answer
57 views

Thread lock algorithm

I am trying to make a thread lock for a method so that only one thread can run it at a time. Although this is a well known issue and in C# there is the lock keyword to do it. I was trying to do it on ...
3
votes
0answers
137 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 ...
4
votes
0answers
216 views

Quicksort async vs serial

I am playing with async and I figured I'd write a parallel implementation of Quicksort while trying to look at various optimizations. I want to keep the generics ...
3
votes
2answers
29 views

Keep database lookup in memory and get values in frequent

Is there a way to write it in more efficient and modern (Up to date design pattern) way? ...
7
votes
3answers
96 views

Displaying a wait cursor while we're waiting

I come from VB6 where everything is single threaded, so I've never written a lick of multi-threaded code before. I just added a wait cursor to one of our GUI's by stumbling through the docs, but I'm ...
1
vote
1answer
27 views

DebugTimer design

Summary: I created this DebugTimer class so that I could test performance of code in a much cleaner/shorter syntax. Prior I was using regular timers and wrapping them all in ...
1
vote
2answers
242 views

Calculate Total of Items in List

I would like to convert the following procedure to use Linq, but I'm not sure how to accomplish it, ForEach or Sum? ...
5
votes
2answers
159 views

Select Items from List using Array

Is there a better way to write this procedure? ...
1
vote
1answer
40 views

Performance shifting for SQL Database and Linq memory grouping

I am messing around with shifting between stored procedures and business layer EF getting data rapidly then processing in memory. This works and on a static data range of 3 months I get execution ...
2
votes
0answers
44 views

Reverse every k nodes of a linked list [closed]

Given a linked list and a number k, Reverse every k nodes in the list. Input: 1->2->3->4->5->6 and k = 1 Output: 2->1->4->3->6->5 How can I ...
-2
votes
1answer
56 views

Need to simplify the big method

Please find below method. It contains some complex logic. That is very difficult provide all the things here. My intention is need to simplify the loops and variable naming and other stuffs too. I am ...
3
votes
1answer
44 views

Convertors converting unconverted objects

In my app, I have several convertors, like these two: ...
4
votes
1answer
95 views

Class responsibilities OOP design [closed]

I'm having some questions on creating a design for simple approval workflow. Some arbitrary thing (ItemToApprove) needs approval process. Approval process begins ...
1
vote
2answers
70 views

Reverse linked list using recursion

Here is my code to reverse link list in using recursion: ...
2
votes
1answer
40 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
votes
0answers
53 views

Is it good practice to use the correct data types? [closed]

This might be a stupid question but here goes: I'm unsure whether it's habit, laziness, or the correct thing to do. But I find myself using data types that I simply don't need to use, for the sake of ...
1
vote
1answer
62 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: ...
4
votes
1answer
68 views

Show dialog only once. Other calls should bring dialog to front, but otherwise not have a result

This code works, as far as I can tell, but there's something that just feels wrong about it. The intended flow is like this: If no dialog is showing Show dialog, return result else Move dialog ...
3
votes
1answer
49 views

Slow update function

I've been fiddling with Unity, trying to make nice walking/running animations. So, i found the Stealth tutorial and I used pretty much the same animator as the AI, only I only use Speed and ...
8
votes
3answers
147 views

Calculating Standard Deviations

We were discussing Standard Deviations in chat, so I decided to write a standard deviation calculator: ...
0
votes
1answer
77 views

Running a function every second

Can someone review my timer class that runs some code every second, please? The void it's calling (runCode) is just a void with ...
3
votes
1answer
45 views

Custom TcpListener

I have only been coding C# for a short time and I can't say I'm an expert but I am rather enjoying it. I wondered if you could see any way I could improve my code. ...
3
votes
2answers
61 views

Flatten Hierarchical Data with LINQ

I have a model with a hierarchical structure like this: ...
12
votes
2answers
719 views

Wait, is that variable ever assigned?

One of the inspections we wanted to implement in Rubberduck for the next release, is one that finds all unassigned variables in a VBA project. Implementing this inspection has been ...complicated ...
3
votes
2answers
88 views

Log-reading & String-matching with hashtable for fastest execution speed

I'm currently enjoying this exercise I'm working on for fun: I wish to write optimized code for the searching of particular strings per line in a (very large) file, counting how many exist, and ...
3
votes
2answers
42 views

Excel to serializable object

I've got an Excel file from which I have to read out data to an object to serialize. So far I came up with this solution, and I'm curious if there are any clearer solutions. ...
14
votes
3answers
222 views

Rubberduck's “Extract Method” refactoring implementation

With the ANTLR-powered parser, I was able to reimplement all code inspections from the last release build, and the rest of the inspections on the road map are now implementable. Code inspections ...
2
votes
0answers
45 views

Optimizing a Query in Entity Framework

I'm wondering what can be done to optimize the following. I've tried to note the points at which most of the overhead is occurring. The main two points I see are The call to DiffDays from within ...