c# count number of occurrences in string

C#
char myChar = 'x';
string myString = "xyz";

int count = myString.Count(s => s == myChar);
Source

Also in C#: