How To Count Number Of Character Or ElementOccurrences In A String Using C#
Hello All,
In order to count the occurences of a certain element or character in a string, you need to perform the split() function and subtract the length with one to get the actual count.
In order to count the occurences of a certain element or character in a string, you need to perform the split() function and subtract the length with one to get the actual count.
int count_li = tempListSource.Split(new string[]{"<li>"}, StringSplitOptions.RemoveEmptyEntries).Length - 1;
Comments
Post a Comment