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

Remove Cookies From CookieContainer Class

How To Test Or Check Dead Pixels And Backlight Bleed On Your Monitor Using Dead Pixel Checker In Windows 11