Evil Code 0002 Optional Parameter Vs Method Overloading

Again one of those things which looks so simple, but could drive one mad during debugging. Much before Optional Parameters came in, C# developers used to depend on Method Overloading for mimicking Optional Parameters. Consider a scenario where both exists, what would be the output ? The output would be : The reason behind this … Continue reading Evil Code 0002 Optional Parameter Vs Method Overloading

Advertisements

Evil Code 0001 : Lambda and Ref/out

What would be output of following ?         static void Main(string [] args)         {             List< int> numlist = new List< int>() {1,2, 3, 4, 5, 6, 7 };             CalculateAndPrint( ref numlist);         }           public static void CalculateAndPrint( ref List< int> Num)         {             var n = Num.Where(d => d > Num[2]);               foreach ( var item in n)             {                 Console.WriteLine(item);             }         } The most obvious answer is … Continue reading Evil Code 0001 : Lambda and Ref/out