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
4answers
100 views

Calculating the daily profit of a clinic

I need help with optimizing a piece of code I've written in C#. It is very sloppy right now. I needed to write a code that tracks the amount of money a hospital made at the of the day depending on the ...
7
votes
2answers
63 views

Roll-a-ball controller

I've been toying around with Unity 5 lately, and in an effort to start making an actual game, I've built a ball controller similar to the one found in the Unity tutorial Roll-a-ball. In essence, the ...
4
votes
2answers
54 views

Logic gates simulation

Following this post and this other post here we are with another review request. The code that follows contains the definition of logic gates (binary gates like the AND, OR gate, and unary gates like ...
-5
votes
0answers
25 views
2
votes
1answer
22 views

Getting translated string using reflection and Resource Manager

I wrote the following code to get the translated string from Resource Manager. The method GetTranslatedString is called more than 50 times in my project. ...
4
votes
3answers
51 views

COMpatible+ Google+ Integrations+ Scoping+

So I have part of a library which deals with scopes in Google+ integration, and I'm curious on the overall view of it. Yes, things are stringly typed in one of the methods, that is because this has ...
4
votes
1answer
45 views

Purchase-ordering

This is the Save function on my PurchaseOrder model in my real world production system. This code needs to write the state of ...
4
votes
1answer
70 views

Generate key from array

What do you think about quality of code in this method? It should: Generate new key based on keys in array The key should start with "TG" Code should find the max number in array keys with "TG-" ...
6
votes
1answer
80 views

Faster(?) factorial calculations

I saw this question, but was unable to answer because of my inexistant knowledge of Rust, so I decided to try and write an algorithm on my own and put it for review. There is the casual way to ...
5
votes
3answers
98 views

ASP MVC Controller Unit Test

So I've been writing a unit test using Rhino Mocks to a controller in my ASP MVC application. The test passes, but I'm interested in your opinion and if there's something I should be doing differently ...
-2
votes
0answers
15 views

How can I make this code write to a file on the drive instead of loading it to memory? [on hold]

I've been thinking about this for a while now but I can't see any way to get this to do what I want it to do. Basically, this part of my code exists within a thread of my application. It accepts TCP ...
1
vote
1answer
24 views

Redis Object storage and convertion

I am stepping into a new Realm with this project, Reflection. I have written some working code (below) that will potentially store POCO objects in a redis cache (and eventually backed by Table or ...
7
votes
1answer
358 views

Declaration of bloatedness: the class that knew too much?

I've already expressed concerns about this type's constructor, and I've sort-of* implemented the changes suggested in the answers I got there. Recently I added even more parameters to that ...
8
votes
2answers
71 views

Generating (presumably) unique `nonce` fields for Twitter OAuth

This is code that's part of a library (closed source) that I have that generates a unique nonce value for Twitter OAuth. Essentially, it generates a random number, ...
8
votes
1answer
146 views

Code Fix - changing accessibility

I am trying to get the hang of Roslyn at the moment, and to implement a couple of code fixes for specific fields/properties that should usually be readonly (in the case of a property, to have no ...
2
votes
1answer
43 views

Should a style sheet object know about its target?

Here are three classes in my project. They work as expected. What I'm not sure of is the passing of the target into style sheet. What is going on is that I want the matrix as a whole to be ...
0
votes
1answer
47 views

Thread safe log class which creates log files according to the current date when entry was added

From this question and some help I created a thread safe logging class on which the name of the log file is same as the current date (short date) when the log entry was added. e.g. If I create ten ...
-6
votes
0answers
27 views

Ambiguous “Abstract” in type name [on hold]

Recent changes to a compiler projects create ambiguous use of the "Abstract" word in class names. Particularly, we have class AbstractTypeData which inherits from ...
2
votes
3answers
59 views

Custom Prime Sieve

I've come up with a prime number finder I call the "Progressive Sieve". I wouldn't doubt it if this has already been thought of. Anyway, here is the idea, an implementation in C#, and benchmarks: ...
2
votes
0answers
30 views

Umbraco Macro-Script to grab Contour Form and Node Properties

When it comes to the Umbraco CMS, there are components called "Macro-Scripts" which are essentially a Razor View (.cshtml). They allow you to code a bunch of C# and ...
3
votes
5answers
102 views

Calculating revenue from roller coaster rides

Problem description: The task is to calculate the amount of money earned from roller coaster rides on any given day. There is a queue in front of the attraction. Visitors might be alone or ...
5
votes
2answers
447 views

Thread safe logging class in C# to use from DLL

I tried to sample up a logging class from this question and answer(I want to use this class from C# DLL). Made slight modification mainly to file name, and also how data is written. I am interested if ...
5
votes
1answer
51 views

MVC app to associate users with roles

I'm a beginner to web programming and just started a MVC project from scratch. Because this will become a large project eventually, I would like to make sure that I'm doing things kind of right from ...
2
votes
3answers
79 views

Related classes around generic types

I'm wondering if this code can be simplified. I'm less than thrilled about the fact that I repeat the Draw method in both CatModel and DogModel. For that matter, I'm not real happy that that method is ...
4
votes
0answers
57 views

Sum data that needs to be joined and grouped by

I have a list of patients, Patient class has Prescriptions property, which is a list of ...
7
votes
3answers
323 views

Determine if a binary tree is balanced

I'm currently running through some Cracking the Coding Interview questions and my solution to 4-4 is quite different from any of the given solutions. The question asks to determine if a given binary ...
3
votes
3answers
40 views

Parsing an ExpandoObject into a typed class using reflection

I've spent some time writing a library to parse JSON into a statically typed object. Am I following most of the standard coding guidelines? Any thoughts on what I could do better, or any edge cases ...
7
votes
2answers
49 views

Convert an object to an ordered by SemVer Markdown list

For a small personal project, I am looking to convert an object to an ordered by SemVer Markdown list. You can find the original code for the sort logic here and here for the writing into Markdown ...
13
votes
4answers
1k views

Operations to a bank account

I am a new .NET/C# developer and one issue bugs me ever since I've wrote code the first time. How can I improve this code? Program.cs: ...
-2
votes
1answer
52 views

Which way is better (matching Onion Architecture in MVC pattern) for using Provider?

In onion arch. we have multi layer structre: UI (User interface). BL (Business Logic / Services). RE (Repositories). UI uses BL to get data from RE with some conditions, my question is which is ...
1
vote
1answer
35 views

A more optimized / cleaner way of validating WCF input parameter using IParameterInspector

I'm having a WCF Rest service which does input parameter validation by using the IParameterInspector, before calling the actual service method. I have Implemented ...
1
vote
1answer
35 views

SQL update scripts taking too much memory and doesn't free it up

I have this piece of code that executes update scripts on the database. I have 20 .sql files that contains about 400 update scripts. The overall size of the files is around 60MB. When I execute all ...
-2
votes
1answer
55 views

SqlClient codes that return number of row affected

The codes below is in DLL. Here's the problems that I can identify: 1) Caller won't know what's the exception? 2) Catch exception 1 but throw exception 2. 3) ...
-4
votes
1answer
53 views

How can I optimise this simple piece of code

This code draws a number of cubes on the screen selected from an array in one of three colours. How can I make it more efficient? ...
4
votes
1answer
61 views

MD5 hash generator

I made this code for a simple WinForm for my school project where I want to add other hash and encryption algorithms. I have made it following the algorithm of the official RFC 1321 and the Wikipedia ...
1
vote
1answer
62 views

Class to represent playing card

I admit I'm sort of stuck on this. I couldn't think of a better way of representing the card value that will be used in a playing card game. How well thought out is the casting an enum value to an ...
1
vote
0answers
12 views

Reviewing LLBLGen code for dropdown databinding

I'm using a lookup table to store all my data for comboboxes (like gender male, female etc.), in order to give an easy management tool in my cms. I am using LLBLGen for my DAL. ...
3
votes
1answer
48 views

Dependency injection with Factory pattern sample code

I'm trying to understand and learn about the SOLID principle and especially Dependency Injection (DI) and Factory pattern. Some background: I have a production application that uses some "helpers" ...
1
vote
2answers
69 views

Implementing a generic class and choosing a collection based on a type

In this topic here I have aksed for help to sort out an error while creating a generic class whose method can return a different collection given a type. I received the answer and working solution but ...
2
votes
1answer
43 views

Class simulating a connection among two pins

Following this post and the one before that, here I am asking for a review on another piece of code: the connection among two pins. As usual, be merciless in your review. Here it goes: ...
3
votes
1answer
49 views

Formatting a CAN bus message as a string

I am writing a CAN bus logger application and need to format messages as quick as possible in order to prevent buffer overflows on our device. In some cases I am quick enough, but under heavy loads it ...
3
votes
1answer
31 views

Class simulating a circuit pin (follow-up)

In a previous post I asked for a review on some code I wrote for an open-source project of mine. After the review I made some changes and I wanted to ask you for another round. This time I'm not ...
-6
votes
0answers
25 views

GridControl fill (NullReferenceException) [closed]

I have devexpress gridcontrol which I want to fill with data from predefined DataTable. This is my code: ...
-2
votes
0answers
25 views

AlienTechnology's algorithm for motion detection [closed]

I am making the simple motion detection with Alien Reader and UHF Passive RFID Tag. Finally, I found the AlienTechnology's algorithm in their .NET sample code In ...
1
vote
1answer
45 views

Bitmask type to perform binary operations

Without any specific implementation details, how would you create a bitmask type that wraps binary arithmetic into something easy to read? Ideally, this would be used with an ...
1
vote
3answers
117 views

Checking user access to servers

I have pasted a method I wrote, which is too slow to my liking (easily takes 60+ seconds to execute). The method loops through 12 different servers, checks if userX has access to any of the databases ...
6
votes
2answers
173 views

CRUD commands to SQL database

I have a large application that focuses on using dependency injection. I've made a small (as I possibly could) piece of sample code to make this question more manageable. Essentially, I have a lot of ...
1
vote
3answers
73 views

Implementation of IpV4Address

For legacy reason (guys here LOVE immutable object), I need a struct that contain an IpV4. I can't use System.Net.IPAddress because it's not a struct. So far here what I got: ...
2
votes
1answer
95 views

Functional pattern matching in C#

I recently read a really interesting post on adding functional pattern matching to C#. Here's a quick and dirty implementation using delegates and dictionaries. Right now, I require that ...
6
votes
1answer
63 views

GitHub (and Bitbucket) Pushing Events

This code is for dispatching and handling certain events from GitHub (and also Bitbucket). Things like pushes, issues, etc. can be handled by this system, and strongly-typed objects will be returned. ...