Ich möchte überprüfen, wie oft k erscheint. Das ist was ich bisher gemacht habe und bekomme keine Ergebnisse.Wie kann ich das Gesamtvorkommen von Buchstaben K erhalten?
class Program
{
static void Main(string[] args)
{
int count = 0;
string str = "hnfdjkkedjjykukyukrtrnrkkkkt";
string l;
for (int i = 0; i < str.Length; i++)
{
l = str.Substring(1, 1);
if (l == "k")
{
count++;
}
}
Console.WriteLine("k appears " + count++ + " times");
Console.ReadKey();
}
}
ändern 'l = str.Substring (i, 1) sein,' und es soll –
arbeitet das funktioniert gut –