一段简单的控制台程序 求解释
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2_18
{
class Program
{
static void Main(string[] args)
{
Console.Title = "Console Read 方法应用实例";
Console.WindowHeight = 8;
Console.WindowWidth = 60;
Console.BackgroundColor = ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.Black;
Console.Clear();
Console.Write("请输入一个字符并按Enter键:");
int i = Console.Read();
char ch = (char)i;
Console.WriteLine("您输入的字符是{0},其编码为{1}",ch,i);
Console.WriteLine();
string str = " ";
Console.Read();
Console.Read();
Console.Write("请输入一个字符串(Enter=完成,X=退出):");
while (true)
{
ch = (char)Console.Read();
if (ch == 'x'|| ch == 'X') return;
str += ch;
if (ch == '\n') break;
}
Console.WriteLine("您输入的字符串是:{0}", str);
}
}
}
我想问一下 为甚麽中间那里要写两个读? 我试了一下如果不写就直接退出了........能详细解释一下麻?谢谢指点~~~