× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Impress your friends with LINQ

Neil Smith
Feb 20, 2015
<p>Use LINQ to solve simple problems in the most complicated way possible. Some will be impressed. Others will be embarassed about how you spend your time. Here's Fizz Buzz in 'one' line:</p> <pre>Enumerable.Range(1, 100)   .FirstOrDefault(x =&gt;   { Console.WriteLine( x % 15 == 0 ? "FizzBuzz" :   x % 5 == 0 ? "Buzz" :   x % 3 == 0 ? "Fizz" :   x.ToString()   );   return false;   }   ); </pre> <p> </p>
comments powered by Disqus