using System; using System.Linq; public class Program { public static void Main() { string text = "Hello World... Fine Thanku."; int countSpaces = text.Count(Char.IsWhiteSpace); Console.WriteLine(countSpaces); } }
string str="This is a sample string with blank spaces"; int spaceCount= str.Count(s => s == ' ');
string str="This is a sample string with blank spaces"; int spaceCount= str.Split(' ').Length - 1;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)