日期:2014-05-18  浏览次数:20882 次

大神们,麻烦帮我看看这个程序
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++;
}