c#的helloworld入门程序

来源:百度知道 编辑:UC知道 时间:2024/05/25 15:34:20
using System;
using System.Collections.Generic;
using System.Text;

namespace helloworld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("helloworld");

}
}
}
此时调试启动以后发现结果一闪而过,我在Console.WriteLine("helloworld");的下面直接加入string str = Console.Readline();以达到按Enter键这个结果才消失的目的,加完之后变成这样:
using System;
using System.Collections.Generic;
using System.Text;

namespace helloworld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("helloworld");
string str = Console.Readline();
}
}
}
调试之后说错误,错误 1 “System.Console”并不包含“Readline”的定义 ,那么应该怎么定义?怎么实现按Enter才让结果消失的目的。 高手帮忙指点一下,本人初学。
能具体解释吗?

请写:Console.ReadLine();
C#对大小写严格敏感

Console.ReadLine(); 是读取一行字符串(以Enter键结束)

Console.ReadKey(); 是读取一个字符(随便按什么都可以)

按你的意思应该是用Console.ReadLine();不是Console.ReadKey();吧

对啊,在Main函数尾加语句Console.ReadKey();

把最后一句Readline中小写l改为大写L,就行了

是Console.ReadKey();