Donate

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.
int count_li = tempListSource.Split(new string[]{"<li>"}, StringSplitOptions.RemoveEmptyEntries).Length - 1;

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.