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

cquptzy8522065 2012-03-18 03:40:39
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如何定义啊,提示说没有定义这个东西,谢谢你们了!
...全文
60 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
小艳 2012-03-19
  • 打赏
  • 举报
回复
这。。。
Ch920427 2012-03-18
  • 打赏
  • 举报
回复
呵呵,为什么不报错??你肯定没有运行吧,一写出来都会错了
cquptzy8522065 2012-03-18
  • 打赏
  • 举报
回复
实在是大意了,谢谢。。出来了
EnForGrass 2012-03-18
  • 打赏
  • 举报
回复
[Quote=引用楼主 cquptzy8522065 的回复:]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace p5_6
{
class Program
{
static void Main(string[] args)
{
……
[/Quote]
这个看你编程的细心程度了,出错了,要学会找原因
装逼之王 2012-03-18
  • 打赏
  • 举报
回复
千万别拼写错误
bdmh 2012-03-18
  • 打赏
  • 举报
回复
foreach (char ch in text)

这个text是啥,前面是 texct
EnForGrass 2012-03-18
  • 打赏
  • 举报
回复
string texct = Console.ReadLine();
int i = 0;
foreach (char ch in texct)//改一下红部分改成texct
{
if (ch == 'a')
i++;
}

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧