标题:一段简单的控制台程序 求解释
取消只看楼主
sunapearl
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-10-12
结帖率:100%
已结贴  问题点数:2 回复次数:0 
一段简单的控制台程序 求解释
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);
        }
    }
}

我想问一下 为甚麽中间那里要写两个读? 我试了一下如果不写就直接退出了........能详细解释一下麻?谢谢指点~~~
搜索更多相关主题的帖子: using class 控制台 
2011-10-12 16:05



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-352207-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.039318 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved