大家看我的c#程序为什么会这样?(初学的)~
来源:百度知道 编辑:UC知道 时间:2024/05/12 20:16:11
{
class Program
{
static void Main()
{
string str;
str = "";
Console.WriteLine("请输入:");
while (true)
{
int c ;
char ch;
c = Console.Read();
ch = Convert.ToChar(c);
if(ch == 'q' || ch == 'Q')
return;
Console.WriteLine(ch);
if (char.IsWhiteSpace(ch))
Console.WriteLine("没有输入");
str += (char)c;
if (c == '\n')
break;
}
Console.WriteLine("您输入的内容是:{0}",str);
}
}
}
我输入一个字符1,然后回车,结
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestInput
{
class Program
{
/// <summary>
/// ouput what you input.
/// Null, notice user : nothing input
/// q/Q: will exit this commandline app
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
bool exitApp = false;
while (true)
{
if (!exitApp)
{
string input = string.Empty;
Console.WriteLine("Input what you want:\n(Null, notice user : nothing input;\nq/Q: will exit this commandline app)");
while (true)
{
input = Console.ReadLine();
if (input.Equals("q") || input.Equals("Q"))
{
Console.WriteLine("Exit this commandline app, welcome to use again");
exitApp = true;
break;
}
else