© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
3 replies
Turwaith

FizzBuzz as short as possible

With a little help from StackOverflow I came up with this:

List<string> testList = new List<string>();
testList.Add(Enumerable.Range(1, 200)
                    .Select(n => n % 15 == 0 ? "FizzBuzz"
                               : n % 3 == 0 ? "Fizz"
                               : n % 5 == 0 ? "Buzz"
                               : n.ToString()).ToString());
List<string> testList = new List<string>();
testList.Add(Enumerable.Range(1, 200)
                    .Select(n => n % 15 == 0 ? "FizzBuzz"
                               : n % 3 == 0 ? "Fizz"
                               : n % 5 == 0 ? "Buzz"
                               : n.ToString()).ToString());

Now it adds only one element though, which is
"System.Linq.Enumerable+SelectRangeIterator'1[System.String]"
"System.Linq.Enumerable+SelectRangeIterator'1[System.String]"
. How do I get this expression to have one list object for each number?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

How to make an expression as short as possible
C#CC# / help
2y ago
Processing files as fast as possible
C#CC# / help
3y ago
✅ How to deserialize as fast as possible?
C#CC# / help
4mo ago
✅ Short Unique Id
C#CC# / help
9mo ago