如何在C#中从控制台读取一行?
ReadLine()方法用于在C#中从控制台读取一行。
str = Console.ReadLine();
上面将在变量str中设置该行。
示例
using System;
using System.Collections.Generic;
class Demo {
static void Main() {
string str;
// use ReadLine() to read the entered line
str = Console.ReadLine();
// display the line
Console.WriteLine("Input = {0}", str);
}
}输出结果
Input =
上面,我们使用Console.ReadLine()方法显示了一行。该字符串由用户从命令行输入。
热门推荐
10 元旦联谊祝福语简短精辟
11 老人过大寿祝福语简短
12 团队文案祝福语简短励志
13 老爸生日暴富祝福语简短
14 今日祝福语简短10字
15 怎么生孩子祝福语简短
16 古诗生日祝福语简短独特
17 怎么说祝福语简短
18 很暧昧的简短祝福语