Console.WriteLine("There are total {0} of char '{1}' in your input string.",count,find_c);
int index = 0;
int n;//第n個(gè)find_c
Console.WriteLine("Please input the SEQUENCE of the char '{0}' in your input string:", find_c);
n = Convert.ToInt32(Console.ReadLine());
if (n > count)
{
Console.WriteLine("Error:The Num must be less than or equal to {0}.",count);
Console.ReadKey();
return;
}
for (int j = 1; j <= count; j++)
{
index = a.IndexOf(find_c,index);
if (j == n)
{
break;
}
else
{
index = a.IndexOf(find_c,index+1);
}
}
Console.WriteLine("The Index of the No.{0} char '{1}' in your input string is {2}.", n, find_c, index);
Console.ReadKey();
}
} |
|