41
votes
Converting DataTable to List of class
I created an extension method for DataTable to convert them into a List<T>
...
41
votes
Country code lookup for each line in a CSV file
Your loop is close to 200 lines, that's waaaay too long. That's long for a full class, let alone one method, let alone part of one method.
Why do you use ...
30
votes
Accepted
Find the odd occurrences in an array
There is a simple solution that does not require a dictionary:
...
26
votes
Accepted
PermMissingElem- find the missing element in a given permutation in C#
It is possible to solve the problem without sorting the array (which is expensive). The input array is actually a simple arithmetic sequence 1, 2, 3, 4 ... N+1, the ...
25
votes
Solving Fizz Buzz using LINQ in C#
Parallel computing and asynchonous computing are two separate things. While they might be similar in some cases, the two terms have two very distinct meanings in C#-land:
Asynchronous computing is ...
24
votes
Accepted
Single line FizzBuzz solution in LINQ
Overall, I like this. It is concise, and neat, and all. My only beef is the nested ternaries.
In general, ternary operator precedence is complicated by the lack of blocks.... The need for the ...
20
votes
Accepted
SudokuSharp Solver with advanced features
This is amazing. Especially for person who is not using C# every day for years.
My main concerns are
too many thing that are public that should be ...
19
votes
Imposing a sort order on a query
I'm not a member of the “goto is evil and must not be used under any circumstances” camp. Especially in performance-critical low-level routines, it can be useful ...
18
votes
18
votes
Accepted
Imposing a sort order on a query
You could use goto, but you can also just define a function, as the label returns a value anyways. For example, your label ...
17
votes
Country code lookup for each line in a CSV file
Instead of using linq lookups for the lists you should map your data into dictionaries, which are MUCH faster to access specific instance of your data, memorywise you might take a hit but the mapping ...
16
votes
Accepted
Increment up the build number in AssemblyInfo.cs on every build
Why not use Regex.Match instead of using those confusing joins/splits? Unless you are purposely trying to code golf this, doing it using regular expression is much ...
16
votes
Accepted
I had one job to do
I would say yes, there is value in removing the foreach loop, because your code will more appropriately mirror what you're expecting to happen versus what can happen. It's unclear to someone looking ...
15
votes
Single line FizzBuzz solution in LINQ
Your code is nice, relatively simple and a good attemp at LINQ - I've written very similar code before. However I have the following critiques:
A list is created unnecessarily, eagerly loading the ...
15
votes
Using C# properties for simple operations, where should I draw the line?
Methods Set and Get Properties through their Get and Set ...
15
votes
Accepted
Using C# properties for simple operations, where should I draw the line?
I think that most things are said, I recapitulate and add some of my own stuff:
As Jesse said, I'd use Any instead of Where + <...
15
votes
Accepted
Wait, is this... LINQ?
Decomposition
There are redundancies in translating from Array and Collection.
Consider these three snippits
...
15
votes
Accepted
ExactlyOne extension method
Q&A
Is the code readable?
ExactlyOne states very clearly what the method is supposed to do.
source is null seems odd to ...
15
votes
Solving Fizz Buzz using LINQ in C#
Understanding your code was a bit of a challenge (albeit an interesting one).
Overall, I see a lot of function definitions that don't seem to accomplish anything. Why did you write
...
14
votes
Accepted
Fetching data from a database
You can try the .Any function on IQueryable. It is made for checking if there are any records.
Remember that .Any() has an ...
14
votes
Accepted
LINQ query that filters elements from a list of object
You can simply combine the conditions inside the FirstOrDefault() like
...
13
votes
Increment up the build number in AssemblyInfo.cs on every build
Don't try to be a badass cowboy. ☺
Stuffing everything onto one line of code is trying to be badass. You could improve clarity simply by adding whitespace.
Producing an incremented version number ...
13
votes
Accepted
Update first and last item in List<T>
The performance of your current code depends a little about the implementation of the list, but what I primarily would have done is to extract first and ...
13
votes
Sudoku Solver - Recursive Solve
At a really quick glance at the Section.RefactorPossibilities() method I can give you some general suggestions
be consitent with the style you use. Here the ...
13
votes
LINQ query that filters elements from a list of object
What you are doing is filtering PersonResultList to only include female genders. Joining to add information from PersonList ...
13
votes
Accepted
Filter data with optional parameters
IEnumerable<Registration> all = All(); // <-- this gets all registrations from
// the database.
This looks ...
12
votes
Get distinct combinations of numbers
Let's talk algorithms, and complexity..... and what the actual problem is that you are trying to solve.
Background
Three concepts: distinct, permutation, and combination
Distinct
Distinct values ...
12
votes
Imposing a sort order on a query
Goto's are a poor-man's function without the return semantics. Take your code, add a function, and bingo!
...
12
votes
Accepted
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
linq × 603c# × 587
performance × 80
entity-framework × 75
.net × 56
xml × 22
extension-methods × 20
algorithm × 17
sql × 16
beginner × 15
datetime × 15
asp.net × 15
linq-to-sql × 15
strings × 14
comparative-review × 14
asp.net-mvc × 14
hash-map × 13
iterator × 13
lambda × 13
generics × 11
.net-datatable × 11
functional-programming × 10
vb.net × 9
reflection × 9
expression-trees × 9