读书人

大神们麻烦帮小弟我看看这个程序

发布时间: 2012-03-29 12:53:12 作者: rapoo

大神们,麻烦帮我看看这个程序
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace p5_6
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入一个字符串:");
string texct = Console.ReadLine();
int i = 0;
foreach (char ch in text)
{
if (ch == 'a')
i++;
}
Console.WriteLine("字符a共出现{0}次", i);
}
}
}



那个text如何定义啊,提示说没有定义这个东西,谢谢你们了!

[解决办法]
string texct = Console.ReadLine();
int i = 0;
foreach (char ch in texct)//改一下红部分改成texct
{
if (ch == 'a')
i++;
}

读书人网 >C#

热点推荐