C# (13)


How C# built-in types are implemented internally?

This is a quick guide to internal implementation of such C# types as Dictionary, Hashtable, List and others.




Equals & GetHashCode: Why is it important to override both?

It is important if your item will be used as a key in a dictionary, or HashSet, etc – since this is used to group items into buckets (in the absence of a custom IEqualityComparer). If the hash-code for two items does not match, they may never be considered equal and Equals() will never be called. […]




Executing SQL script with GO statement from C# code

In the middle of a project you might want to automate DB restoring and upgrading  by means of existing SQL scripts which may contain GO-statements. If you are that person who is attempting to execute scripts at runtime with GO-statements, this article describes how to do that.




Calculation of PowerSet on C#

This text explains a binary algorithm to calculate a power set of any sequence. It has a sample code in C#.




Error: DbArithmeticExpression arguments must have a numeric common type.

From time to time you need to filter data by difference between two dates. For instance, you wanna take a difference between date from a record and Today.




Error: Unable to determine the principal end of an association between the types

You may get this error if you have entities related to itself. For example, you have a tree hierarchy.




Post JSON objects with nested classes to MVC action

Default view model binding of ASP.NET MVC has a disadvantage when using view models with nested classes and JSON objects. The binding is unable to recognize such nested classes and it initializes them to NULL value. This text describes a cause and solutions.




Speeding up calculation of an average in continuous processes

Processing big sets of data can cause a low performance due to inefficient calculations. In order to overcome this issue we should rewrite calculations in a way which allows getting results using the latest data about sequence. This text describes an algorithm of  sequential average.



String Expression Calculator

Parsing of math equations from text expressions is the interesting thing. This task is close to LL parsing but can be solved in different ways. This approach tends to be the simplest one.




Disabled control in a DataGridView cell

From time to time you need to show a disabled control within DataGridView control. As you might already know, a grid cell has ReadOnly property which is not useful for the case because controls still looks enabled even if they are placed in disabled cell.