char[] ch = str.ToCharArray(); //返回输入字符串的单个数组形式
int total = 0; //用来计算有多少个满足用户输入的字符个数
for (int i = 0; i < ch.Length; i++)
{
if (ch[i] == Convert.ToChar(target))
{
total++;
}
}
string ss = null;
for (int i = 0; i < ch.Length; i++)
{
if (ch[i] == Convert.ToChar(target))
{
ss+=(i + 1).ToString()+",";
}
}
Console.WriteLine("共有{0}项匹配",total);
Console.WriteLine("他们分别是第:{0}项",ss);