ShareThis

Monday, June 25, 2012

[C#] Count instances of a string in string with LINQ


// This will count the number of occurrences of 'X' in your string.
// You can look for strings and characters!
int total = yourString.Count(x => x == 'X'); 



0 comments:

Post a Comment