We pay for user submitted tutorials and articles that we publish. Anyone can send in a contribution
Learn MoreLast 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:
Copyright © 2012 Dev102.com
Breeze : Designed by Amit Raz and Nitzan Kupererd