In this post, here is the VB.Net 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 codes for the same method, you can use whatever you want. Method 1 :
”’ Method to count the occurrences of a charcter in a string
”’ <param name=”inputString”>InputString</param>
”’ <param name=”SearchChar”>character to count</param>