In this post, here is the c# code to count the occurrences of a particular character in a given string.
Suppose there is a case where we may want to check whether the string contains particular character or not.
And we may want to count the occurrences of the character, in that case you can use this method and if count =0, then it means the character is not found.
Below are the 2 methods for the same logic, you can use whatever you want.
Method 1 :
/// Method to count the occurrences of a charcter in a string
///<param name=”SearchChar”>character to count</param>