Enumerable Tips & Tricks with String and Int
Useful things to do with Enumerable in a single line
System.Linq.Enumerable is a core of LINQ magic.
Most of the functions we use in a daily basis for anything we write with sequence, but what is really interesting is that methods from this class can be used for some tricky operations on strings and numbers and make them one line instead of loops.
Here are some which I found interesting.
Multiply string in one line
String.Concat(Enumerable.Repeat("*", 14))
Reverse an array
Enumerable.Reverse("Hello".ToArray());
Range of numbers in array
Enumerable.Range(1, 10);
Complete list of static methods in Enumerable class you can find on MSDN website and direct link is listed in a refernces of this page.
Do you have any new interesting usage of Enumerable class method?
Please submit in your comment.
References
Disclaimer
Purpose of the code contained in snippets or available for download in this article is solely for learning and demo purposes. Author will not be held responsible for any failure or damages caused due to any other usage.
Comments for this article