{
var x = new List<string>();
x.Add("1");
x.Add("1");
x.Add("1");
x.Add("21");
x.Add("23");
x.Add("55");
x.Add("68");
x.Add("55");
x.Add("sac");
x.Add("ez");
int c = 0;
foreach (var item in x)
{
if (item == "1")
{
c = c + 1;
}
}
Console.WriteLine(c);
}
Count Occurrences of a Character Inside a String
string source = "111122211234532145671";
int count = source.Count(f => f == '1');
Console.WriteLine(count);
https://www.delftstack.com/howto/csharp/count-occurrences-of-a-char-in-a-string-in-csharp/