count how many letters in a string c# code example
Example 1: find character from string c# count
int count = Regex.Matches(test, "word").Count;
Example 2: count number of characters in an int c#
/// You can do this two ways.
/// First way (below)
public int getcharsforeach(int l) {
int charnum = 0;
foreach (char c in l.ToString()) {
charnum += 1;
}
return charnum;
}
/// Second way (below)
public int getcharlength(int l) {
int letters = l.ToString().Length;
return letters;
}