Count the number of strings in another string in C# / .NET

Introduction: In many times during development, We face the problem to find the solution to know how to Count the number of strings in another string in C# / .NET. Here In this Article, I will let you know about it in details

Details Description: Let me discuss a scenario, Let’s suppose you have a string “His Name like ‘Don’ and Don(Oversmart) and so on”, I need to 1)find how many times Don is available on string, 2) How many times ‘Don’ string available or 3) how many time Don(Oversmart) is available in string. Their type of question will be resolved by this article.

Useful Links

  1. The difference between Machine.Config and Web.config
  2. Create Serial Number in SSRS
  3. Clear dropdown values using JavaScript
  4. Flipkart affiliate API in C#,ASP.NET
  5. Bluehost Discount Coupon: Save up to 63% with Free Domain

Method – 1: You need to create an Extension method for this as given below

How to call this Extention Method in Application: this as simple as we work with other application.

Method 2: Using Regular Expression

Feedback: If this article is helpful to you, Please give your feedback to us. Thank you

Live Demonstration of this Article,

Anand Kumar
@anandkumarv

Anand Kumar

Sr.Tech Lead at CsharpMagic
I am founder of csharpmagic.com and by profession Sr.Tech Lead. I like to explore New Technologies, New Business idea and many more
Anand Kumar
@anandkumarv

Latest posts by Anand Kumar (see all)

Anand Kumar

I am founder of csharpmagic.com and by profession Sr.Tech Lead. I like to explore New Technologies, New Business idea and many more

Leave a Reply

Your email address will not be published. Required fields are marked *