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