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

-1
votes
0answers
14 views

Reversing the items in single linked list [on hold]

I have the following code to reverse the elements within the given range of m and n where 1<= m <= n <= length of the list. ...
-5
votes
1answer
42 views

How can this C# code be improved? [on hold]

I am trying to get a better result with this code. Do you have any advice? ...
5
votes
3answers
176 views

Deleting all the matching items in single linked list

I have the following code which I implemented to delete all the nodes for the matching value. My code handles all the 63 varieties of test case scenarios including scenarios like deleting 1 from ...
3
votes
1answer
45 views

Proxy web service which handles three different input structures

I'm a newbie and I'm new to C# (thus statics and copy-paste) and I'm painfully aware that this code smells. I'm trying to implement a web service that handles a similar pass-through logic with three ...
5
votes
0answers
43 views

Efficiently checking if a large enumeration has a consistent order

The scenario is as follows: We have a streamed enumeration that we have to check if it's ordered or not before processing it (about 75-80% of the time it is ordered). We are talking about pretty big ...
5
votes
1answer
454 views

Design patterns for console commands

I've made a pretty standard console in which you type a command and it does something. However, the issue that comes to my mind is scaling: if I want to add hundreds of commands, I have to manually ...
0
votes
0answers
9 views
2
votes
1answer
44 views

Custom byte cipher

I posted a custom byte cipher on this site a few months back, and after spending three days recoding it from scratch, wanted to post it again to see if you can offer any improvements. (I am not ...
6
votes
2answers
194 views

Reverse binary representation of an int (only significant bits)

This based on this question in StackOverflow. The accepted answer uses Convert.ToString(int, base) to get the binary string, ...
-1
votes
2answers
53 views

Accessing a list of websites using a configuration read from an XML file [on hold]

I have a C# application and a CakePHP website. These communicate between them using GET and (WebRequest) POST method. My problem is that it's happening too fast. I have made a diagram that shows ...
5
votes
1answer
89 views

Async access to School

I have this class with two public async methods, which also calls some private methods that are async. Here's the class: ...
6
votes
2answers
73 views

Redis Message Queue (Cloud)

I am in the process of writing a Cloud application (mostly hobby, learning) that required a very quick cache, queue, and messaging system. I have looked at a few different options from Microsoft ...
5
votes
1answer
61 views

Library to convert any number to a metric expression

For a small personal project, I was looking to write a number as a human readable number. For example: 1023 -> 1K 12345678 -> 12M Stack Exchange, like a ...
3
votes
1answer
82 views

Creating items in a game

I've created some base classes for items, and I want to know how maintainable or expandable the method seems. ...
-3
votes
3answers
38 views

Write object data to CSV files [on hold]

Does this method follow the rules of objective programming? If not, how can I change it? ...
4
votes
0answers
34 views

Item-level locks for a large number of items

Background I'm working on a system that records information about a large number of external documents. These documents are organized by "repository". There can be a modest number of repositories ...
5
votes
3answers
89 views

Filter a list of persons by age and write the results to a relevant file

Let's say I have a class: ...
7
votes
3answers
284 views

“Dice on a Yacht” game

I wrote a small program to address some assignment tasks related to making a game called 'Dice on a Yacht'. I sent the code to be reviewed by a company I was applying for, and I have not gotten the ...
4
votes
1answer
44 views

Highlight Current Link

I'm using this technique for highlighting current links (e.g. how the "Questions" link is highlighted on this very page you're looking at). I changed the code a little bit and came up with this ...
2
votes
0answers
51 views

Choose the right type for method GetById

I design my repository class and I need some advise from you. Now I have method GetByID that return generic type. ...
-3
votes
0answers
14 views

Calling methods from BusinessLayer or WCF [on hold]

I will develop a layered application. It will contain DataAccessLayer, ModelLayer, BusinessLayer, WCF Service Layer and Presentation Layer. I want to write all business logic code in BusinessLayer and ...
2
votes
0answers
22 views

Method that return related entities using OData

There is method GetFull that should use OData return related entities. When I call GetFull(12, "entity1,entity2") then I will ...
5
votes
1answer
61 views

Implementing an IRC Bot

So this is a (fairly) simple IRC bot. The whole idea of it was similar to Duga, except that it will post to an IRC server instead. The bot takes messages from a SQL table and posts them in the IRC ...
0
votes
1answer
41 views

Procedural generation of an infinite map made up of 1's and 0's

This is my function to procedural generate an infinite random map of 1's and 0's it only calculates what you can see at the time and when the view moves it calculates the next rows. Complexity is the ...
3
votes
3answers
652 views

Convert Foreach Loop into Linq in C#

I want to convert these loops into simple loop. I want the code to look neat and short. I saw answers related to LINQ but couldn't make out from that. Are there any other possible ways for this ...
0
votes
0answers
45 views

Entity framework and disconnected graph [on hold]

Is there any way for EF to automatically detect which properties should be updated / added / deleted / ignored when dealing with a disconnected graph? In an application I am creating I am using a WCF ...
3
votes
2answers
56 views

Proper way to insert a record and assign the id to the Entity object

Scenario: I need to insert a record in a database and use the id resulting from that operation for every other operation needed. So I've created a class that contains all details of the object that ...
0
votes
1answer
36 views

Defining application flow in ASP.NET MVC5

Currently I am assigned to a project which has a standard view-flow, yet this flow is determined by whether settings are set to either true or false. So, for example, let the standard flow be ...
1
vote
2answers
147 views

Getting a user's property

Can this extension method be improved? ...
6
votes
2answers
595 views

Decorator for cars

Is this a good use of the decorator pattern? If not, why not? Is this a good idea to use for example when we have objects communicating with MVC through PHP or via ASP? To send data through the model ...
-5
votes
1answer
58 views

Dependency injection using a constructor class for a boolean class method [closed]

This code is the interface to implement method returntrueotrue to return a boolean of true or true which is a logical: ...
4
votes
1answer
81 views

Dynamic Language Interpreter in C#

This code interprets an abstract syntax tree generated by a recursive descent parser for a dynamic scripting language called Hassium. The syntax of this language looks like this ...
4
votes
3answers
196 views

Simple cache dictionary

I decided to write a simple dictionary to use as a cache: ...
6
votes
4answers
180 views

Finding the floor value in an array

Problem: Given an sorted array of N distinct integers, find floor value of input 'key'. Say, A = {1, 2, 3, 5, 6, 8, 9, 10} and key = 7, we should return 6 as outcome. How can I optimize my ...
-5
votes
0answers
37 views

Calculator using while loop in c# [closed]

here is my code .there is no any error. but i am not getting any output, if i press y or n so please reply me . if u have any suggestion.thank you. ...
3
votes
2answers
151 views

Loading Active Directory users by username and by SID

I have many different methods like ones below, but is there way I could improve them and remove duplicate code ? ...
3
votes
0answers
30 views

Rewriting to single pipeline by using data flow blocks

I have a number of messages with a payload as a list of items. My goal is to transform the message payload without losing the relation between the message and payloads. Isn't it possible to rewrite ...
3
votes
1answer
73 views

Ability System in my game

I'm writing a game in C# Monogame, and I've decided to make my project as modular as possible. GitHub At first, I've had a single project with a folder that's separated inside to other folders ...
3
votes
1answer
36 views

Reading headerless image style and performance

This code is working and was tested for over 10000 images. I have many headerless images, i.e images which are binary files with known dimensions. Some of the images have a visible area which is ...
9
votes
5answers
150 views

Return the longest word (or words) in a string

I'm coding for a function that checks the longest word (or words) in a string: If multiple words are of the same size, those words have to be displayed. If a single word is inputted, that word has ...
4
votes
2answers
176 views

“Breaking out” elements from an array

I wrote a method that takes an array T[] array (T is a type parameter) and a second array ...
4
votes
2answers
44 views

Displaying separated multi-line text fields

The following code grabs the HTML-encoded, multi-line content of a text field. It then splits the content on line breaks, and finally displays it with commas as separators. I would like to have this ...
5
votes
3answers
98 views

Poker game implementation

I have included almost all features that real poker game contains, but even tho I tried to make it as clean as possible, I think it can be done much better. I used inheritance to somewhat distinct ...
1
vote
0answers
34 views

Create JSON object from self-nested LINQ query

I created this function to created nested JSON object using a Linq query. How can I optimize this and make it more readable? ...
8
votes
1answer
60 views

Replacement string Base64 (and a Base32) conversion

This provides (my own) implementation of ToBase64String and FromBase64String (since the .NET implementations suck), and a ...
2
votes
0answers
29 views

Different data sources for UnitOfWork and Repository patterns

I was involved in some code-review discussions about UnitOfWork and Repository pattern implementation with EF, which put me in ...
7
votes
3answers
136 views

Parsing pipe delimited lines

I am parsing the following line of code via a specific format. Line is: S|111111|87654321|Bar UK|BCreace UK|GBP|24/08/2010| The Format is: ...
3
votes
0answers
25 views

Efficient .net/Win32 interop code

This is a function definition from an external dll, that I'm calling from my code: ...
6
votes
3answers
527 views

Checking two lists for equal items

I'm using this code for checking if two List<T> are equal or not: ...
11
votes
1answer
205 views

Framework to track changes and relationships in C#

Recently, I wanted to see how I might could track state changes to objects, and manage relationships (1 to 1, 1 to N, N to N) between types in C#. This was a really interesting project, and I'm ...