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

Bootstrap Modal In ASP.NET MVC With CRUD Operations