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

5
votes
1answer
20 views

Method to return date ranges of 1 year

I made a method that takes 2 DateTimes as a parameter, a startDate and a stopDate. The ...
1
vote
1answer
18 views

Restoring data from database to list with SQLite

I have a Winforms project in which I have a screen which loads a questionnaire. It restores answers the user has previously entered by restoring the saved results from the database to a single list (...
2
votes
1answer
29 views

Testing whether webapp-generated reports match expected output

I'm new to coding and have cobbled together some code to run an automated test against a web application. The code works but I have some complexity rule violations (CA1505, CA1502 and CA1506) and ...
0
votes
0answers
9 views

Edit or Update User Asp.net MVC [on hold]

Hello i'm trying to edit a user in asp.net mvc 5 The issue is i got null the id, i update a specific user when i click in the button from my index. ...
3
votes
0answers
67 views

Read and write in C# buffer in parallel

I have a buffer - int array with defined length. I want to read and write values into this array in parallel. For instance, 5 readers and 3 writers with different ...
11
votes
4answers
2k views

Converting the weight of a potato into a letter grade

I've just started learning C# using Rob Miles' C# Programming Yellow Book and some related lab exercises from his website. I did one of them and produced a solution that works. In Miles' book, he says ...
2
votes
2answers
102 views

Filtering a list by comparing enums against a user choice

I have a list of objects where one of the properties on the object class is an enum. The program below simply loops through each item in the list, checks an int value, then checks the enum value for ...
2
votes
1answer
31 views

Unfold a 2D array spiral in C#

The purpose of this function is to turn a 2D array of sorts into a single-dimensional array by reading it in a spiral fashion. In the array: 1 2 3 4 5 6 7 8 9 ...
3
votes
2answers
46 views

Building a summary string from a flags enum

I'm trying to replicate the attributes text that appears in File Explorer, for files and directories. I can't just use the enum names, as the summary text uses a single character for each set flag, ...
1
vote
1answer
37 views

Trying MVVM on timer app

Check me: Model should do everything. That's where all functionalities and features are accommodated. It has some properties, that I can access and use. ...
4
votes
0answers
36 views

Split string to space-separated words based on dictionary

This program is based on as old retired Google interview question where you're supposed to create a program that will split a string into space-separated words, if the string is composed of valid ...
4
votes
0answers
38 views

WebApi controller in C#

I went into new company, so my code wasn't perfect, but they forced me in PR to make something like this that I personally do not agree. ...
7
votes
1answer
155 views

A Binary Editor with Live Text Preview

This is a tool I needed for some other things (it's incomplete, but almost done) which is essentially just a text-editor that has two text-boxes: the left being the binary view / raw bytes, the right ...
2
votes
3answers
89 views

Hackerrank Insertion Sort Algorithm 1 (creating duplicates to show shifting)

During an interview, I was given this Hackerrank question to solve within 15 minutes but at that time I was interested in solving this without performance in my mind. I know a similar question has ...
-6
votes
0answers
43 views

Orange Ya Glad? [on hold]

Heh??? Heh??? Pretty good, eh? ...
2
votes
1answer
51 views

Synesthesia for the rest of us (i.e. algorithm for unique string colorization)

I'd like to form an algorithmic connections between a particular string and and a particular color, in such that each unique string is always the same color. My particular use case is for a kiosk ...
1
vote
1answer
32 views

Trie-based spell checker

This is a classic problem with a classic solution and I've seen it a number of times on this site, but I wanted to know what people thought of this C# implementation, as opposed to the numerous C ...
4
votes
4answers
207 views

Storing values or calculating values

I am trying to decide between two designs of a class. The basic difference is the one calculates properties when they are called, and the other when the object is instantiated. I would usually just ...
4
votes
6answers
123 views

Show a diamond shape with numbers

After seeing this post on StackOverflow, I thought I'd try it out. What I have now is a diamond shape with numbers like this: ...
1
vote
1answer
38 views

Ensuring no race conditions in my concurrent/parallel ForEachAsync method

Hopefully the final chapter of my ForEachAsync code review. The original question was the starting point and the second question contained modifications suggested in the original trying to ensure I ...
-4
votes
0answers
32 views

String Mathematical expression without RPN [on hold]

Accepting an mathematical expression in a string format from the user, like e.g. 2*5 or 9/5+9 or 91-10+82/3, 325-69+584 C#. ...
3
votes
3answers
102 views

Prime factoring function using recursion

As a programming exercise, I decided to make a prime factoring function using recursion: ...
1
vote
1answer
36 views

Parzen Window Density Estimation in C#

Is my implementation correct (it is matching this result)? How can I improve this code? ...
-1
votes
0answers
31 views

How to add filter to stored procedure to compare in c# class? [on hold]

Explain of code: I have an stored procedure where I get values to populate graphic. So now I get two diferent values one is TotalReal and ...
-1
votes
0answers
11 views

Suppresses reporting of a specific static analysis tool rule [on hold]

I am currently reading code that i am unfamiliar with. The code has a hand written ViewModel or similar approach for Windows Forms. Inside the class ViewModelBase ...
4
votes
1answer
39 views

Passive View implementation in c# MVP

I have a c# WinForms application in which I have tried to implement the Model View Presenter pattern with Passive View. The View derives from a parent IView which propagates the public members and ...
-3
votes
0answers
20 views

Using Sorted Derived ObservableCollection Class [on hold]

for my Project I need an ObservableCollection Class. This class can fire Events when something changed. After looking for some Ideas on the web I found a really good answer here : http://www.dotmaniac....
-3
votes
0answers
23 views
4
votes
2answers
129 views

Square root function

As a programming exercise I made a square root function in C# using recursion, here is the function: ...
3
votes
3answers
180 views

Coffee making program

I work mainly at developing MSSQL databases but I've been trying to teach myself C# for a bit now and I wrote some simple code that prints a list of colleagues and their coffee preference. I just ...
4
votes
1answer
46 views

Semaphore based concurrent work queue

There's a need to have a mechanism in place that will process messages received from the network concurrently. However, only X number of messages can be allowed to be processed concurrently and there'...
-4
votes
2answers
184 views

Separation of one list into 2 list by one key [on hold]

Is there any other way to write this separation? ...
5
votes
2answers
333 views

Visual boardgame

The visual boardgame is currently a game in unity, where I've created a map and a grid. The visualization is like this: Making this code obviously needed nested for loops and the like, but developing ...
3
votes
2answers
79 views

Delimited File Reader

UPDATE: I have refactored the code into a Gist using @Dmitry's answer as a guide. The update is much simpler to grok, implements IDisposable, and is roughly thirty ...
2
votes
1answer
46 views

Business rule check inside DAL service [closed]

At now I have such code, creating or updating some entity by dto items. ...
2
votes
2answers
105 views

High performance, branchless Intersection testing: sphere-aabb & aabb-aabb

From my tests: AABB-Sphere: 2954.8 tests per ms. AABB-AABB: 1087.0 tests per ms. The sphere test is almost 3 times faster, but the two intersection tests seem to perform about the same number ...
2
votes
3answers
126 views

Pangrams implementation using Linq

This is a continuation of my LINQ stories from Pangrams-Hackerrank. Similarly, this challenge has been asked before in python Pangrams python Implementation but I have tried to accomplish this ...
7
votes
1answer
100 views

Constant keys thread safe dictionary

I find that I use this pattern a lot where I have a dictionary which I would only read from and update and wouldn't add/remove keys. In that case, using ...
3
votes
0answers
56 views

C# cache controller (Followup)

This is a followup to the question: C# cache controller Suggestions taken onboard from previous feedback, and refactoring to shorten the code in the calls to the cache controller by allowing queries ...
0
votes
0answers
12 views

Getting mixed up with Publish() [closed]

I'm working on an extension method which returns regular "timeout" values when an observable source has pauses. ...
3
votes
2answers
55 views

Diagonal difference using Linq

Recently, I have been trying my hands on LINQ. So I've implemented the diagonal difference using Linq in Hackerrank. I know a similar question has been asked in python Diagonal Difference Here is ...
3
votes
2answers
95 views

Implementing SOLID Principles - LINQ TO SQL

I have been using Layered Architecture in my web application. Can anyone please advise if my data layer classes (both Linq and booking class) can be improved? I have just started learning about solid ...
-3
votes
0answers
34 views

Basic Calculator Need Help C# [closed]

I have made a C# calculator console project that takes in basic questions (+,-,*,/) but I don't know how to make it accept decimals and large numbers (like 23524564252452.56356).I am quite new to ...
5
votes
2answers
93 views

Generic thread-safe data structure

I wrote the following class so that a single object can be shared across many threads. Is using the ReaderWriterLockSlim redundant in this case and only ...
1
vote
1answer
55 views

Moderation library

Here is a moderation library that I have coded and would like some help in improving the quality of my code. Most of the code is styled by rules of Resharper; Resharper has helped me out a lot with ...
4
votes
3answers
308 views

Downloading blobs asynchronously

We have a working implementation that is doing I/O operations, returning data from blobs in an async/await manner from Azure Blob Storage. ...
1
vote
1answer
29 views

Standardizing Controller + Service method signatures

In my controllers, I have the following: ...
2
votes
2answers
81 views

Player Permission System

I have coded a fully working permission system for my gaming emulator to determine permissions for users. What I really want to know is: Is my code standard good enough? Is the design of the class ...
2
votes
1answer
58 views

Using Concurrent Dictionary and Lazy<T> to cache expensive query results and only run query once in a threadsafe manner

Ok, so I'm querying a webservice. This webservice is slow with multiple o's. I want to cache the results of the query, because I only want to query on a given set of parameters once during my ...