tag:blogger.com,1999:blog-7113888591536837437.post4829963693812423652..comments2017-03-16T03:23:27.461-07:00Comments on Code Liability: FizzBuzz c# 3.0D. Mark Lindellhttp://www.blogger.com/profile/06102973229672434002noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-7113888591536837437.post-82316281525762105462008-03-26T05:47:00.000-07:002008-03-26T05:47:00.000-07:00Yes, I messed up with the rules and the math... ma...Yes, I messed up with the rules and the math... man I suck at details.D. Mark Lindellhttps://www.blogger.com/profile/06102973229672434002noreply@blogger.comtag:blogger.com,1999:blog-7113888591536837437.post-45206918758335699222007-10-17T12:59:00.000-07:002007-10-17T12:59:00.000-07:00finally a chance to write a truly useful extension...finally a chance to write a truly useful extension method...<BR/><BR/>(from n in Enumerable.Range(1, 100) select n.fizzBuzz()).ToList().ForEach(Console.WriteLine);<BR/><BR/>public static class FizzExtensions<BR/>{<BR/> public static string fizzBuzz(this int n)<BR/> {<BR/> return (((n % 3) == 0) ? "fizz" : "") <BR/> + (((n % 5) == 0) ? "buzz" : "") <BR/> + (((n % 3) != 0) && ((n % 5) != 0) ? n.ToString():"");<BR/> }<BR/> }Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-7113888591536837437.post-22154129473290149442007-10-15T09:40:00.000-07:002007-10-15T09:40:00.000-07:00That's pretty cool, but that's not the way I play ...That's pretty cool, but that's not the way I play FizzBuzz:<BR/><BR/>(from n in Enumerable.Range(1, 100)<BR/> select (((n % 3) == 0) ? "fizz" : "") <BR/> + (((n % 5) == 0) ? "buzz" : "")<BR/> + (((n % 3) != 0) && ((n % 5) != 0) ? n.ToString():""))<BR/> .ToList().ForEach(Console.WriteLine);James Curranhttps://www.blogger.com/profile/03689643776077649326noreply@blogger.com