C# 中 Read() 和 ReadLine() 方法有什么区别?
Read()
Read() 从标准输入流读取下一个字符。如果在控制台上按下某个键,它便会关闭。
int a = Console.Read() Console.WriteLine(a);
ReadLine()
它从标准输入流读取下一行字符。
示例
using System;
class Program {
static void Main() {
int x = 10;
Console.WriteLine(x);
Console.Write("
Press any key to continue... ");
Console.ReadLine();
}
}输出
10 Press any key to continue...
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP