Fizz Buzz in LINQ
November 1, 2017
Here's a simple implementation of FizzBuzz using LINQ:
List<string> lResults = new List<string>(); IEnumerable<int> lOneToHundred = Enumerable.Range(1, 100); lOneToHundred.ToList().ForEach(i => lResults.Add(i % 15 == 0 ? "FizzBuzz" : i % 3 == 0 ? "Fizz" : i % 5 == 0 ? "Buzz" : i.ToString())); foreach (string lValue in lResults.Take(20)) …