char myChar = 'x';
string myString = "xyz";
int count = myString.Count(s => s == myChar);
# cCopyusing System;
using System.Linq;
namespace get_first_char_of_string
{
class Program
{
static void Main(string[] args)
{
string source = "/once/upon/a/time/";
int count = source.Split('o').Length - 1;
Console.WriteLine(count);
}
}
}
string source = "/once/upon/a/time/";
int count = 0;
foreach (char c in source)
if (c == '/') count++;