Last week, I stumbled upon the following piece of code:
IList<double> doubles = new List<double> {22.123, 400.12, 100.22}; foreach (int number in doubles) { Console.WriteLine("The Current Number Is : {0}", number); }
Can you see the bug in that code? We convert all of the doubles in the list to integers, truncating them. I was very surprised that the compiler didn’t warn me about this issue, especially because the compiler would not let me write this code:
DataTemplates are a great feature introduced in WPF, it allows to determine how data is presented and how data binding accesses the presented data. Just as we can apply a visual style to a specific UI control, we can do it for a specific data type. There is just one problem here, DataTemplates are good [...]
Whenever we need to implement an interface in C#, two options pops up (click Ctrl+’.’):
Implicit vs explicit interface implementation, what shall be selected? before making a decision, lets understand what is the difference between those two.
Solving the diamond problem:
The diamond problem is related to object oriented languages that allow multiple inheritance. The problem raises when [...]
We pay for user submitted tutorials and articles that we publish. Anyone can send in a contribution
Learn More