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
0answers
16 views

Clarification on the logic for saving xml file and getting ids [on hold]

I have List of List<Student>, that is: List<List<Student>> I have to ...
9
votes
2answers
124 views

Async wrapper around public API

Tear it apart. I'm mostly concerned around the appropriate use of ConfigureAwait(false), and possible poor handling and duplication of the ...
3
votes
3answers
64 views

Mapping uint to value within set [min,max]

I have a method that transforms any input uint into a [min,max] set. I am looking if I can improve the function, specifically to get rid of the ...
2
votes
0answers
22 views

Binding data to a ComboBox and then showing ValueMember in another TextBox

I have a comboBox and a TextBox in the View and when the view is loaded, the ...
3
votes
2answers
163 views

How can I better my URL checker program?

I made a LinkChecker program which checks URLs from a text file and outputs status into another file like this: ...
0
votes
0answers
9 views

Need to use floats for performance yet want double-precision calculations [migrated]

MonoGame is an open-source version of Microsoft's XNA. It's a framework for building cross-platform games. It has a number of mathematical types such as Vector and Quaternion. I am a bit baffled by ...
2
votes
2answers
13 views

Resize image with good quality and less weight

I want to resize an image with good quality, and the most important thing is having less weight for an image so that webpages will load it faster. I am using the below method for this. Please check ...
2
votes
1answer
94 views

Faster file lookup

I'm polling an ashx handler to check if a specific file is present and return true or false depending on it. ...
4
votes
1answer
29 views
3
votes
2answers
47 views

performance on this substring search

I have the code below that gets hit several hundred times per second. I'm wondering what I can do to improve performance. It seems that there should be some way to build up a substring index. Is there ...
3
votes
0answers
27 views

Binding a DataGridView to a List

I'm new to Databinding in MVP and I want to bind my DataGridView to a object list. This grid may be populated in two ways. There are TextBoxes in the form and users can enter text, and when they ...
3
votes
1answer
42 views

Entity Framework - updating two different arrays of child associations

Exercises have Muscles and Tools. When someone adds or updates an ...
5
votes
2answers
71 views

Compare string with wildcard string

I have the following function to compare a string with a wildcard string (containing ? and *), as C# doesn't seem to have a builtin function to do it. ...
9
votes
1answer
234 views

Update first and last item in List<T>

I am trying to do the following. I have a list of Custom objects: ...
13
votes
5answers
504 views

Parsing CSV to specific format

I've written this code to read CSV files written to a specific format. I would like to gather some feedback on where it could be improved. I'm trying to get into the test driven development ideology ...
2
votes
3answers
37 views

Is Dictionary the right data structure for this?

I have an object which represents historical price of certain financial instrument as below: ...
9
votes
6answers
1k views

Divide two numbers, then apply a custom rounding rule

If the fractional part of the number is greater than 0.6, round up; if less, round down. I need feedback about my code. ...
2
votes
1answer
33 views

Cross Thread Access to Object in ViewModel

This is a fairly straight forward question. I have a C# WPF MVVM application that call a C++ DLL to do some compilation/crunching. To update the UI C# application for progress updates I am using ...
3
votes
1answer
46 views

When should I actually derive from my interface?

Context: I am working on an XNA project, and since procedural generation is likely to be used, I wanted to eventually create a helper class to work with data to facilitate that. Design Goal: ...
20
votes
3answers
2k views

What are the best practices with multithreading in C#?

For a while I have been interested in seeing if some tasks work well when split across multiple threads. On the one project I have been busy with I have been creating a lot of small utility apps, to ...
2
votes
0answers
12 views

What are the best practices with multithreading in C# [duplicate]

For a while I have been interested in seeing if some tasks work well when split across multiple threads. On the one project I have been busy with I have been creating a lot of small utility apps, to ...
2
votes
0answers
29 views

EF6-Lambda Expressions deep big-tree query

I am looking to improve the following query. We are using EF6 (CodeFirst) and C# Lambda Expressions, and Repository/Unit of Work patterns. Also, we needed to restrict the query in a way that we ...
3
votes
4answers
211 views

Generating 2 comma-separated lists from list of key value pairs

Could this code: ...
2
votes
4answers
320 views

Silent Try_catch in high load socket server or not?

I'm working on a socket application that will listen to incoming messages from about 400 devices. They all send a message at least once per minute. Now I have a working program and it has been running ...
3
votes
1answer
58 views

Should I null coalesce EventArgs?

When I implement events, it usually looks something like this: ...
0
votes
1answer
51 views

Drawing multiple Images

Im trying to draw a lot of fields image for my world generation, all is perfect 64 fps, but if i began to draw all the time the grass it became laggy, like 59 fps (something that musn't happen! :( ), ...
5
votes
1answer
60 views

Message Based Communication Design

I'm trying to design an API.NET for some communication purposes with Testing Equipment and I cannot figure out a proper way for designing the architecture. Basically, we have different (physical) ...
5
votes
1answer
38 views

Verifying the type of an AggregateException's inner exception in a unit test

I've got the following code inside an integration test. ...
4
votes
1answer
55 views

Unit of Work / Repository nHibernate

I have a Unit of Work / Repository pattern in place to abstract away some nHibernate. Most examples I've seen though use the pattern a little differently. In ...
2
votes
1answer
37 views

Parsing ODataQueryOptions<T> to Expression<Func<T, bool>>

I am following up on this answer for a scenario that I am currently working on. Like the OP, I am too concerned about the longevity of the code. ...
4
votes
1answer
62 views

Method to return a string of max length (in bytes vs. characters)

In my (c#) code, I need to generate a string (from a longer string) which when UTF-8 encoded, is no longer than a given max length (in bytes). ...
0
votes
0answers
37 views

Advanced programming Advice to separate code for classes? [closed]

Quick question, Now further in my career I have found that I am still sticking with some of my bad coding techniques, such as Coding directly into the Event (such as the _ButtonClick event), instead ...
6
votes
1answer
98 views

Abstract Factory Pattern C# Example

I am working through more tutorials on Design Patterns and came across the Abstract Factory Pattern. I extended it out a bit (the example that is) and want your opinion: ...
3
votes
0answers
57 views

PreWarmCache for MVC Application with Stopwatch Infinite Loop

I used the information from the article "Auto-Start ASP.NET Applications (VS 2010 and .NET 4.0 Series)" to create a background task that runs on an infinite loop. Ultimately, this program is going to ...
9
votes
1answer
363 views

Chunk Generation Performance in C#

I'm working on a game in C#, this game generate new chunk (infinite) when you move around. If I have > 1000 chunks in my list then it become laggy even though I only load the necessary chunks on my ...
6
votes
4answers
1k views

Regex validation for Email Address

I need to validate whether my regex is correct for below scenario. Suggestion's if the regex is correct: Wiki Link Local_part The local-part of the email address may use any of these ASCII ...
-1
votes
0answers
12 views
10
votes
3answers
689 views

Does everyone still love Fibonacci?

I'm following up on this question. I made a few decisions about my model and implemented recommendations accordingly. TL;DR the link Uses a loop algorithm to return a Fibonacci number \$Fn\$ of ...
4
votes
3answers
126 views

Refactor C# Linq code to reduce duplication

I currently have the below code: ...
5
votes
1answer
37 views

Negative Lookbehind Regex

I have the following code which attempts to match all strings like "*SOMESTRING" (which can include numeric values), but not "*SOMESTRING*". For this I am using a negative lookahead as follows;...
3
votes
2answers
51 views

Find all file occurences of a search term on drive

I have written a small application that lets the user search drives for their given input string. I am only returning the full name of files. What I have now is the following method to retrieve those ...
20
votes
4answers
2k views

Everyone loves Fibonacci

I was bored and burnt out on more serious projects.... until I saw this Computerphile video on YouTube. Now I'm inspired again. Now I feel like spending some time implementing that recursive algorithm ...
2
votes
1answer
56 views

Cleaning User Input

I am not sure if I am approaching this task the correct way. I have a view model with multiple string properties. I pass the model through an interface to a service class that contains a void to ...
3
votes
3answers
63 views

Validating a string under few conditions

Following code validates NIC number of a person (National Identity Card, no like SSN) Requirements are... Length should be 10 digits or characters All should be digits except the last one Last one ...
2
votes
1answer
40 views

Using a single validation handler for all controllers in a form

In input validation I'm using this validation method in my all Forms. Here I have a single handler for all TextBoxes in my Form and if I have other controllers like ...
5
votes
2answers
58 views

Convert string to multiline text

I made this method that takes any string and transforms it into a multiline text l; each line having the max (character) length specified by the rowLength ...
10
votes
1answer
129 views

Tweets per second, using linked list

This is a TalentBuddy Challenge Your task is to write a function that prints to the standard output (stdout) the highest number of tweets recorded between each second in the array and the past ...
9
votes
2answers
75 views

Extending database factory class to use auditing class

I'm the the process of adding change auditing to my existing DB class which encapsulates database calls. Previously I would just pass in a ...
3
votes
4answers
144 views

Input validation for text boxes in a Form

In a Win Form I'm doing initial validation in the Form. So before saving data, I want to validate whether all the required fields are filled (Text Boxes) by the user. There are about 18 such Text ...
2
votes
1answer
52 views

Is my ObjectCache wrapper sound?

Wrapper: ...