int count = 0; foreach(char c in s) { if(c == 'a') count++; }
int count = 0; for (int i = 0; i < s.Length - 1; i++) { if(s[i] == 'l') count++; }
//Chaine string taChaine = "abafjdsklgjlajdfklsjgklaa"; //Lambda int nb taChaine.Count(c> c == 'a'); button1.Content = nb.ToString(); //Linq nb = (from c in taChaine where c == 'a' select c).Count(); button1.Content += " " + nb.ToString(); //Regexp var reg = new System.Text.RegularExpressions.Regex("a"); nb = (reg.Matches(taChaine)).Count; button1.Content += " " + nb.ToString(); //Split nb = (taChaine.Split('a')).Length - 1; button1.Content += " " + nb.ToString();
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questioncombien il y a de ``a`` de ``f`` de ``g`` et de ``s`` dans abcdefffgijkl
taChaine.Count(c => c == 'a')