From IT Skills
Jump to: navigation, search

Performance[edit]

In computer science, an associative array, map, symbol table, or dictionary is an abstract data type composed of a collection of (key, value) pairs, such that each possible key appears at most once in the collection... dictionary problem, a classic computer science problem... two major solutions to the dictionary problem are a hash table and a search tree... directly addressed arrays, binary search trees... tree is reasonably balanced, which is to say the leaves at either end are of comparable depths... advantage is that B-trees do not need to be re-balanced as frequently

Lookup times are different in List and Dictionary... O(1) constant time complexity. The List has an O(N)

Variables[edit]

прохання всім при оголошенні змінної з ініціалізацією не вказувати явно тип а писати var. І утримуватись від оголошень змінних без одночасної ініціалізації.

тобто, замість:

string regexInvalidPathChars = "[" + Regex.Escape(wrongSymbols) + "]";

хотілось би бачити як:

var regexInvalidPathChars = "[" + Regex.Escape(wrongSymbols) + "]";

а замість

SomeClass obj = SessionLoad("bla-bla");

мати:

var obj = SessionLoad("bla-bla") as SomeClass;

LINQ[edit]

.Contains(pr); // better than
.Exists(mf => string.Compare(mf, pr) == 0);

delegate[edit]

An event is just a wrapper for a multicast delegate. Adding a public event to a class is almost the same as adding a public multicast delegate field... delegate is a .NET object which points to a method that matches its specific signature.

Action is a delegate (pointer) to a method, that takes zero, one or more input parameters, but does not return anything. Func is a delegate (pointer) to a method, that takes zero, one or more input parameters, and returns a value (or reference). Predicate is a special kind of Func often used for comparisons.

lambdas are just syntactic sugar for anonymous delegates

runtime[edit]

Short-lived objects are stored in the first generation, generation 0. The longer-lived objects are pushed into the higher generations, 1 or 2. The garbage collector works more frequently in the lower generations than in the higher ones.

other C# guides[edit]

Pages in category "CSharp coding guide"

The following 7 pages are in this category, out of 7 total.