Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 6172

C# is a multi-paradigm, managed, garbage-collected, object-oriented programming language created by Microsoft in conjunction with the .NET platform. Use this tag for questions related to C#. In case a specific version of the framework is used, you could also include that tag; for instance .net-2.0.

5 votes
Accepted

Is this an ok implementation of an UnorderedPair?

One thing: I would make the struct immutable since mutable structs have really bad unintended effects. Otherwise, this is a good, solid implementation. public struct UnorderedPair<T> : IEquatable<Unor …
Jesse C. Slicer's user avatar
19 votes
Accepted

List<T> Any vs Count, which one is better for readability?

For me, it's about intent. What does your code's business logic say if you read it in English (or your native language)? It usually comes to me as "If there are any employees who are in the managemen …
Jesse C. Slicer's user avatar
1 vote

how to avoid switch-case

Here you go: static void Main(string[] args) { ConsoleHelp ch1 = new ConsoleHelp(); Plus pl = new Plus(); Minus mn = new Minus(); Divide dv = new Divide(); Multiply mlt = new Mult …
Jesse C. Slicer's user avatar
5 votes

Advice to improve code in simple webpage

Simplify your properties with the as operator: private List<string> CRIDS { get { return ViewState["CRIDS"] as List<string>; } set { ViewState["CRIDS"] = value; …
Jesse C. Slicer's user avatar
2 votes

Rolling Average class sanity check

Couple of small bits: The arguments to your ArgumentOutOfRangeException exception are in the wrong order. I eliminated the padLock member variable, because the counts member variable is perfectly co …
Jesse C. Slicer's user avatar
2 votes

How to know when I need to use get/set and when not?

I'd probably go one farther - if this class has an immutable state in that number (I don't know the use case for your actual class), make it immutable as such: public sealed class Example { priva …
Jesse C. Slicer's user avatar
1 vote

new Class().Function() pattern

Sometimes this does stink. Consider the following: byte[] data = { ... }; File.OpenWrite("filename.dat").Write(data, 0, data.Length); File.OpenWrite implements IDisposable and therefore should be …
Jesse C. Slicer's user avatar
2 votes

SHA1 Hash Checker

Your code is full of boilerplate and what seems to be misunderstood bits of the language as well as outmoded naming schemes. What I will show below does the following: Eliminates a number of interme …
Jesse C. Slicer's user avatar
3 votes
Accepted

Binary-reading code

Try a pair of methods like this: public T GetValue<T>(int position, Func<T> readFunc) { long oldPosition = this.memoryStream.Position; this.memoryStream.Position = position; T value = re …
Jesse C. Slicer's user avatar
6 votes

Create an array with random numbers

You don't need to new up a new random number generator every time. In fact, doing so may result in the same sequence of "random" numbers being generated if they're called too fast in succession (it ba …
Jesse C. Slicer's user avatar
6 votes

Next Instance of DRY Refactoring

What is the point of empty public constructors? If there's no logic in them, remove them. The PropertyGetter class member in multiple classes is never assigned to after it is initialized. Mark them r …
Jesse C. Slicer's user avatar
5 votes
Accepted

Less code vs More readable

I would argue that neither version is readable enough. Extract 'til you drop. I would say in the grand scheme of things, you should wind up with very small bits of code that do atomic tests and almost …
Jesse C. Slicer's user avatar
3 votes

Group by range and include edge duplicates

I would generalize it as an extension method: public static IEnumerable<IEnumerable<U>> GroupByValueRange<T, U>( this IEnumerable<T> items, int rangeSize, Func<T, double> getValue, Fun …
Jesse C. Slicer's user avatar
7 votes
Accepted

Get the character and its count which has highest occurrence

As per this answer, it would be wiser to use a tuple in this case. I use lowercase "t"uple as I highly recommend the built-in language support for tuples (char, int) over the explicit Tuple<T1, T2> de …
Jesse C. Slicer's user avatar
3 votes

Repository for data retrieval

I'd expand on the repository a bit with adding a few operations to the interface and implementing them as well as making your GetAll() and Filter() methods return IQueryable instead (as they are queri …
Jesse C. Slicer's user avatar

1
2 3 4 5
20
15 30 50 per page