Count occurrences of a string within a string
C# Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 | class Program { static void Main(string[] args) { string text = "this| is| a| sample text"; int count = text.Split('|').Length - 1; Console.WriteLine(text + " / " + count); Console.ReadLine(); } } |
Output:
1 2 3 | this| is| a| sample text / 3 |
Find the number of occurrences of a character in a string using c# linq
Find the number of occurrences of a character in a string using c#,
Count repeated words in string using c#,
Count occurrences of character in string c#,
Find all occurrences of a substring in a string C#,
How to count the occurrence of each character in a string in c#,
How to find most repeated word in a string in c#,