You’ve heard about LINQ to SQL, LINQ to Objects and LINQ to XML right? Well how about LINQ to String? Well technically there is no such thing. But you use LINQ on a string! You may not have realized this before but it works. LINQ can be used to query IEnumerable<T> and a string is actually a collection of chars. So yup, you can actually query the string itself. Here are a few simple examples but you certainly do a lot more than this…
public void LinqToStringSample() { string letters = "keuiwierqewefqwfwefcjlkjkl"; //count all 'e' int count = letters.Count(l => l == 'e'); //order var ordered = letters.OrderBy(l => l); }
Remember Me
.Net (55) asp.net (8) asp.net mvc (2) Ben (19) Blog (6) C# (7) Code Camp (28) Entertainment (2) Family (21) Fun Stuff (4) General (19) Hiking (1) jquery (1) LINQ (7) Microsoft (15) MOQ (2) Movies (2) MSBuild (2) MVVM (2) NoDeNUG.org (4) NUnit (3) Orbius (2) Philly.Net (49) Sarah (1) Silverlight (14) SQL Server (3) Subversion (2) Tech-Ed 2007 (3) Technology (24) Travel (2) Unit Testing (2) Vista (7) Visual Studio (3) Web (9) Windows 7 (2) Windows Phone 7 (1)
Powered by: newtelligence dasBlog 1.9.6264.0
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
© Copyright 2012, Andrew Schwam
E-mail