首先深入研究C# [英] First delve into C#

查看:43
本文介绍了首先深入研究C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这里完成n00b,所以请耐心等待。


我写了下面的代码,想知道是否可以优化
。特别是,我正在读取操作数的用户输入到

变量strOperand,而不是使用IF语句来确定要使用哪个
操作数,我'我想使用可变内容

例如dblAnswer = dblFirstNo strOperand dblSecondNo


另外,最后的While子句...理想情况下,我想写点什么

就像

while(strMore!=" y"和strMore!=" n")


但我不知道该怎么做。


任何帮助表示赞赏。

代码****************************** ******

static void Main(string [] args)

{

//声明默认使用的变量值

double dblFirstNo = 0,dblSecondNo = 0,dblAnswer = 0;

string strMore =" y",strOperand =" *" ;;


//继续,直到用户输入n

而(strMore ==" y")

{

//获取第一个数字

System.Console.WriteLine(请输入数字);

dblFirstNo =


System.Convert.ToDouble(System.Console.ReadLine());


//问他们是什么与数字有关

System.Console.WriteLine

(请输入操作数(* / + -

) );

strOperand =

System.Console.ReadLine();


//获取下一个数字

System.Console.WriteLine(" Please enter another number" );

dblSecondNo =


System.Convert.ToDouble(System.Console.ReadLine());


//确定使用的操作数并执行计算

//这也不理想,但我不知道如何使用

//操作数作为变量并使其作为操作数工作!

if(strOperand ==" *")

{

dblAnswer = dblFirstNo * dblSecondNo;

}

else if(strOperand ==" /")

{

dblAnswer = dblFirstNo / dblSecondNo;

}

else if(strOperand ==" +")

{

dblAnswer = dblFirstNo + dblSecondNo;

}

else if(strOperand ==" - ")

{

dblAnswer = dblFirstNo - dblSecondNo;

}

//输出总和和答案

System.Console.WriteLine

(" {0} * {1} =

{2}",dblFirstNo,dblSecondNo,dblAnswer);


//询问用户是否想要继续

strMore =" z" ;;

while(strMore ==" z")

{< br $>
System.Console.WriteLine

(你想要

输入更多? (y / n)");

strMore = System.Console.ReadLine();

//检查用户输入的内容

//是Y

if(strMore!=" y")

{

// nope is it n

if(strMore!=" n")

{

//将它设置为z所以


//系统可循环

//允许......不这么认为,


//但它会做到

//我越来越精通

strMore =" z";

}

}

}

}

}

Complete n00b here, so please bear with me.

I have written the following code and would like to know if it could be
optimised. In particular, I''m reading the user input for the operand into
variable strOperand, and rather than use the IF statement to determine which
operand to use, I''d like to use the variable contents
e.g. dblAnswer = dblFirstNo strOperand dblSecondNo

Also, the While clause at the end...ideally, I would like to write something
like
while (strMore != "y" and strMore !="n")

but I don''t know how to do this.

Any help appreciated.
Code ************************************
static void Main(string[] args)
{
//declare the variables to be used with default values
double dblFirstNo = 0, dblSecondNo = 0, dblAnswer = 0;
string strMore = "y", strOperand = "*";

//keep going until the user enters "n"
while (strMore == "y")
{
//get the first number
System.Console.WriteLine("Please enter a number ");
dblFirstNo =

System.Convert.ToDouble(System.Console.ReadLine()) ;

//ask what they want to do with the numbers
System.Console.WriteLine
("Please enter an operand ( * / + -
)");
strOperand =
System.Console.ReadLine();

//get the next number
System.Console.WriteLine("Please enter another number" );
dblSecondNo =

System.Convert.ToDouble(System.Console.ReadLine()) ;

//determine the operand used and perform the calculation
//this isn''t ideal either, but I don''t know how to use
//the operand as a variable and get it to work as an operand!
if (strOperand == "*")
{
dblAnswer = dblFirstNo * dblSecondNo;
}
else if (strOperand == "/")
{
dblAnswer = dblFirstNo / dblSecondNo;
}
else if (strOperand == "+")
{
dblAnswer = dblFirstNo + dblSecondNo;
}
else if (strOperand == "-")
{
dblAnswer = dblFirstNo - dblSecondNo;
}
//output the sum and the answer
System.Console.WriteLine
("{0} * {1} =
{2}",dblFirstNo,dblSecondNo,dblAnswer);

//ask if the user wants to continue
strMore = "z";
while (strMore == "z")
{
System.Console.WriteLine
("Do you want to
enter more? (y/n)");
strMore = System.Console.ReadLine();
//check to see what the user entered
//was it Y
if (strMore != "y")
{
//nope was it n
if (strMore != "n")
{
//set it to z so the

//system can loop
//ideal...don''t think so,

//but it''ll do until
//I get more proficient
strMore = "z";
}
}
}
}
}

推荐答案

它在我看来,你希望用户按照说明操作,并且

不会打字,因为你的代码要求用户输入一个数字,然后

解析字符串输入到一个数字,而不检查它是否是一个

数字。如果用户输入非数字输入,您的应用

将崩溃。你需要实现一些检查。例如,您可以使用

System.Double.TryParse来检查输入。例如:


bool isNumeric = false;

double dblFirstNo;

字符串输入;


while(!isNumeric)

{

input = Console.ReadLine();

isNumeric = Double.TryParse(输入,输出) dblFirstNo);

if(!isNumeric)

Console.WriteLine("你没输入数字。请输入一个数字

" ;);

}


参见 http://msdn2.microsoft.com/en-us/lib....tryparse.aspx

- -

HTH,


Kevin Spencer

微软MVP

鸡肉沙拉射击器
http://unclechutney.blogspot.com


一个男人,一个计划,一条运河,一个有着......哦,没关系的回文。


Billy < Bi *** @ discussion.microsoft.com写信息

新闻:8F ************************* ********* @ microsof t.com ...
It looks to me like you''re expecting the user to follow instructions, and
not make any typos, as your code asks the user to enter a number, and then
parses the string input to a number without checking to see if it is a
number first. In the event that a user enters a non-numeric input, your app
will crash. You need to implement some checking. For example, you could use
System.Double.TryParse to check the input first. Example:

bool isNumeric = false;
double dblFirstNo;
string input;

while (!isNumeric)
{
input = Console.ReadLine();
isNumeric = Double.TryParse(input, out dblFirstNo);
if (!isNumeric)
Console.WriteLine("You did not enter a number. Please enter a number
");
}

See http://msdn2.microsoft.com/en-us/lib....tryparse.aspx
--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.

"Billy" <Bi***@discussions.microsoft.comwrote in message
news:8F**********************************@microsof t.com...

在这里完成n00b,所以请耐心等待。


我写了以下代码,想知道是否可以优化
。特别是,我正在将操作数的用户输入读入

变量strOperand,而不是使用IF语句确定

其中
$ b要使用$ b操作数,我想使用变量内容

例如dblAnswer = dblFirstNo strOperand dblSecondNo


另外,最后的While子句......理想情况下,我想写一下

的东西

喜欢

while(strMore!=" y"和strMore!=" n")


但我不知道怎么做这样做。


任何帮助表示赞赏。


代码****************** ******************

static void Main(string [] args)

{

//声明要与默认值一起使用的变量

double dblFirstNo = 0,dblSecondNo = 0,dblAnswer = 0;

string strMore =" y", strOperand =" *" ;;


//继续,直到用户输入n

而(strMore ==" y")

{

//获取第一个数字

System.Console.WriteLine(" Please enter a number);

dblFirstNo =


System.Convert.ToDouble(System.Console.ReadLine());


//问w他们想用数字做帽子

System.Console.WriteLine

("请输入一个操作数(* / + -

) ");

strOperand =

System.Console.ReadLine();


//获取下一个数字

System.Console.WriteLine(" Please enter another number" );

dblSecondNo =


System.Convert.ToDouble(System.Console.ReadLine());


//确定使用的操作数并执行计算

//这也不理想,但我不知道如何使用

//操作数作为变量并使其作为操作数工作!

if(strOperand ==" *")

{

dblAnswer = dblFirstNo * dblSecondNo;

}

else if(strOperand ==" /")

{

dblAnswer = dblFirstNo / dblSecondNo;

}

else if(strOperand ==" +")

{

dblAnswer = dblFirstNo + dblSecondNo;

}

else if(strOperand ==" - ")

{

dblAnswer = dblFirstNo - dblSecondNo;

}

//输出总和和答案

System.Console.WriteLine

(" {0} * {1} =

{2}",dblFirstNo,dblSeco ndNo,dblAnswer);


//询问用户是否想要继续

strMore =" z";

while (strMore ==" z")

{

System.Console.WriteLine

(你想要

输入更多? (y / n)");

strMore = System.Console.ReadLine();

//检查用户输入的内容

//是Y

if(strMore!=" y")

{

// nope is it n

if(strMore!=" n")

{

//将它设置为z所以


//系统可循环

//允许......不这么认为,


//但它会做到

//我越来越精通

strMore =" z";

}

}

}

}

}
Complete n00b here, so please bear with me.

I have written the following code and would like to know if it could be
optimised. In particular, I''m reading the user input for the operand into
variable strOperand, and rather than use the IF statement to determine
which
operand to use, I''d like to use the variable contents
e.g. dblAnswer = dblFirstNo strOperand dblSecondNo

Also, the While clause at the end...ideally, I would like to write
something
like
while (strMore != "y" and strMore !="n")

but I don''t know how to do this.

Any help appreciated.
Code ************************************
static void Main(string[] args)
{
//declare the variables to be used with default values
double dblFirstNo = 0, dblSecondNo = 0, dblAnswer = 0;
string strMore = "y", strOperand = "*";

//keep going until the user enters "n"
while (strMore == "y")
{
//get the first number
System.Console.WriteLine("Please enter a number ");
dblFirstNo =

System.Convert.ToDouble(System.Console.ReadLine()) ;

//ask what they want to do with the numbers
System.Console.WriteLine
("Please enter an operand ( * / + -
)");
strOperand =
System.Console.ReadLine();

//get the next number
System.Console.WriteLine("Please enter another number" );
dblSecondNo =

System.Convert.ToDouble(System.Console.ReadLine()) ;

//determine the operand used and perform the calculation
//this isn''t ideal either, but I don''t know how to use
//the operand as a variable and get it to work as an operand!
if (strOperand == "*")
{
dblAnswer = dblFirstNo * dblSecondNo;
}
else if (strOperand == "/")
{
dblAnswer = dblFirstNo / dblSecondNo;
}
else if (strOperand == "+")
{
dblAnswer = dblFirstNo + dblSecondNo;
}
else if (strOperand == "-")
{
dblAnswer = dblFirstNo - dblSecondNo;
}
//output the sum and the answer
System.Console.WriteLine
("{0} * {1} =
{2}",dblFirstNo,dblSecondNo,dblAnswer);

//ask if the user wants to continue
strMore = "z";
while (strMore == "z")
{
System.Console.WriteLine
("Do you want to
enter more? (y/n)");
strMore = System.Console.ReadLine();
//check to see what the user entered
//was it Y
if (strMore != "y")
{
//nope was it n
if (strMore != "n")
{
//set it to z so the

//system can loop
//ideal...don''t think so,

//but it''ll do until
//I get more proficient
strMore = "z";
}
}
}
}
}



比利,


我冒昧地重写你的代码,把它分成几个小b * b小方法。这使代码更容易遵循。拇指规则是,如果你不能同时在屏幕上显示整个方法,那么

方法太长了。如果您输入文本或

无效的操作数,您的代码将崩溃。此外,如果/ if if,交换机比

更快更容易维护。默认情况永远不会发生,但是需要,因为编译器

不知道(或者在切换后放置返回)。而不是

ReadLine我使用ReadKey作为Y / N并隐藏结果。

static void Main(string [] args)

{

do

{

计算();

}

而( DoContinue());

}


静态无效计算()

{

//使用默认值声明要使用的变量

double dblFirstNo = 0,dblSecondNo = 0,dblAnswer = 0;

string strOperand =" *" ;;


//获取第一个数字

Console.WriteLine(请输入数字);

dblFirstNo = ReadNumber() ;


//询问他们想对数字做什么

Console.WriteLine(" Please enter a operandrand(* / + - )" );

strOperand = ReadOperand();


//获取下一个数字

Console.WriteLine(" Please enter另一个数字);

dblSecondNo = ReadNumber();


//得到答案

dblAnswer = GetAnswer(dblFirstNo,strOperand,dblSecondNo);


//输出总和和答案

Console.WriteLine(" {0 } {1} {2} = {3}",dblFirstNo,strOperand,

dblSecondNo,dblAnswer);

}


static string ReadOperand()

{

string operand = Console.ReadLine();

while(operand!=" *" ; &安培;&安培; operand!=" /" &安培;&安培; operand!=" +" &安培;&安培;

operand!=" - ")

{

Console.WriteLine(请输入有效的操作数);

operand = Console.ReadLine();

}


返回操作数;

}


静态双读取数字()

{

双倍结果;

字符串值= Console.ReadLine() ;


while(!Double.TryParse(value,out result))

{

Console.WriteLine(" Please)输入有效数字);

value = Console.ReadLine();

}


返回结果;

}


静态双GetAnswer(双firstNumber,字符串操作数,双

secondNumber)

{

开关(操作数)

{

case" *":

返回firstNumber * secondNumber;

case" /":

返回firstNumber / secondNumber;

case" +":

返回firstNumber + secondNumber;

case" - ":

返回firstNumber - secondNumber;

默认值:

返回Double.NaN;

}

}


静态布尔DoContinue()

{

/ /询问用户是否想要继续

Console.WriteLine(你想输入更多? (y / n)");


do

{

ConsoleKey k = Console.ReadKey(true).Key ;

if(k == ConsoleKey.Y)

返回true;

else if(k == ConsoleKey.N)

返回false;

else

Console.WriteLine(请输入Y或N);

}

while(true);

}


-

快乐编码!

Morten Wennevik [C#MVP]
Hi Billy,

I''ve taken the liberty to rewrite your code, splitting it into several
smaller methods. This makes the code easier to follow. A thumb rule is,
if you can''t se the entire method on the screen at the same time, the
method is too long. Your code would have crashed if you entered text or
an invalid operand. Also, a switch is faster and easier to maintain than
if/else if. Default will never happen, but is needed since the compiler
does not know that (or put the return after the switch). Instead of
ReadLine I used a ReadKey for the Y/N and hide the result.
static void Main(string[] args)
{
do
{
Calculate();
}
while (DoContinue());
}

static void Calculate()
{
//declare the variables to be used with default values
double dblFirstNo = 0, dblSecondNo = 0, dblAnswer = 0;
string strOperand = "*";

//get the first number
Console.WriteLine("Please enter a number ");
dblFirstNo = ReadNumber();

//ask what they want to do with the numbers
Console.WriteLine("Please enter an operand ( * / + - )");
strOperand = ReadOperand();

//get the next number
Console.WriteLine("Please enter another number");
dblSecondNo = ReadNumber();

// get the answer
dblAnswer = GetAnswer(dblFirstNo, strOperand, dblSecondNo);

//output the sum and the answer
Console.WriteLine("{0} {1} {2} = {3}", dblFirstNo, strOperand,
dblSecondNo, dblAnswer);
}

static string ReadOperand()
{
string operand = Console.ReadLine();
while (operand != "*" && operand != "/" && operand !="+" &&
operand != "-")
{
Console.WriteLine("Please enter a valid operand");
operand = Console.ReadLine();
}

return operand;
}

static double ReadNumber()
{
double result;
string value = Console.ReadLine();

while (!Double.TryParse(value, out result))
{
Console.WriteLine("Please enter a valid number");
value = Console.ReadLine();
}

return result;
}

static double GetAnswer(double firstNumber, string operand, double
secondNumber)
{
switch (operand)
{
case "*":
return firstNumber * secondNumber;
case "/":
return firstNumber / secondNumber;
case "+":
return firstNumber + secondNumber;
case "-":
return firstNumber - secondNumber;
default:
return Double.NaN;
}
}

static bool DoContinue()
{
//ask if the user wants to continue
Console.WriteLine("Do you want to enter more? (y/n)");

do
{
ConsoleKey k = Console.ReadKey(true).Key;
if (k == ConsoleKey.Y)
return true;
else if(k == ConsoleKey.N)
return false;
else
Console.WriteLine("Please enter Y or N");
}
while (true);
}

--
Happy Coding!
Morten Wennevik [C# MVP]


一个非常合理的努力。我已经改写了,你会注意到我已经没有回答你关于while(strMore!=" y和strMore

)的问题。 != QUOT; N")"所以我会在这里做。

你会把它写成

do

{

stuff

} while(aString!=" y"& aString!=" n");使用| (管道)for或。


这是我的努力。我把它放在一个函数中,并为

程序控件添加了一个枚举。该函数是静态的,因此您只需将其粘贴到您的应用程序中,然后使用Calc()调用它;注意换行:)


私人enum PlayAgainOptions

{

无效,playAgain,exitGame

}


private static void Calc()

{

double firstNo,secondNo,result = 0;

字符串操作数;

PlayAgainOptions playAgain = PlayAgainOptions.invalid;


do

{

System.Console.WriteLine(" Please enter a number);

firstNo = double.Parse(System.Console.ReadLine());


System.Console.WriteLine(" Please enter another number");

secondNo = double.Parse(System.Console.ReadLine());


System.Console.WriteLine(" Please enter a operandrand(* / + - )");

operand = System.Console.ReadLine();


开关(操作数)

{

case" *":

result = firstNo * secondNo;

休息;

case" /":

result = firstNo / secondNo;

休息;

case" +":

result = firstNo + secondNo;

break;

case" - ":

result = firstNo - secondNo;

break;

默认值:

//以上都不是!

休息;

}

//在答案中包含操作数

System.Console.WriteLine(" {0} {1} {2} = {3}",firstNo,operand,

secondNo,result);


do

{

System.Console.WriteLine("你想输入更多? (y / n)");

//转换为小写,因此我们也捕获了Y或N.

switch(System.Console.ReadLine()。 ToLower())

{

case" y":

playAgain = PlayAgainOptions.playAgain;

break ;

case" n":

playAgain = PlayAgainOptions.exitGame;

break;

默认值:

playAgain = PlayAgainOptions.invalid;

休息;

}

} while(PlayAgainOptions.invalid == playAgain) ;


} while(PlayAgainOptions.playAgain == playAgain);

}

}

Billy写道:
A perfectly reasonable effort. I''ve rewritten it and you''ll notice I''ve
not answered your question about "while (strMore !="y" and strMore
!="n")" so I''ll do that here.
you would write it as
do
{
stuff
}while(aString != "y" & aString != "n"); use | (pipe) for or.

Here''s my effort. I''ve bunged it in a function and added an enum for
program control. The function is static so you can just paste it into
your app and call it with Calc(); Watch for line wrap :)

private enum PlayAgainOptions
{
invalid, playAgain, exitGame
}

private static void Calc()
{
double firstNo, secondNo, result = 0;
string operand;
PlayAgainOptions playAgain = PlayAgainOptions.invalid;

do
{
System.Console.WriteLine("Please enter a number");
firstNo = double.Parse(System.Console.ReadLine());

System.Console.WriteLine("Please enter another number");
secondNo = double.Parse(System.Console.ReadLine());

System.Console.WriteLine("Please enter an operand ( * / + - )");
operand = System.Console.ReadLine();

switch(operand)
{
case "*":
result = firstNo * secondNo;
break;
case "/":
result = firstNo / secondNo;
break;
case "+":
result = firstNo + secondNo;
break;
case "-":
result = firstNo - secondNo;
break;
default:
// None of the above!
break;
}
// include the operand in the answer
System.Console.WriteLine("{0} {1} {2} = {3}",firstNo, operand,
secondNo, result);

do
{
System.Console.WriteLine("Do you want to enter more? (y/n)");
//convert to lowercase so we capture a Y or N as well.
switch (System.Console.ReadLine().ToLower())
{
case "y":
playAgain = PlayAgainOptions.playAgain;
break;
case "n":
playAgain = PlayAgainOptions.exitGame;
break;
default:
playAgain = PlayAgainOptions.invalid;
break;
}
} while (PlayAgainOptions.invalid == playAgain);

}while(PlayAgainOptions.playAgain == playAgain);
}
}
Billy wrote:

在这里完成n00b,所以请耐心等待。


我写了以下代码并希望要知道它是否可以优化
。特别是,我正在读取操作数的用户输入到

变量strOperand,而不是使用IF语句来确定要使用哪个
操作数,我'我想使用可变内容

例如dblAnswer = dblFirstNo strOperand dblSecondNo


另外,最后的While子句...理想情况下,我想写点什么

就像

while(strMore!=" y"和strMore!=" n")


但我不知道该怎么做。


任何帮助表示赞赏。


代码************************** **********

static void Main(string [] args)

{

//将变量声明为与默认值一起使用

double dblFirstNo = 0,dblSecondNo = 0,dblAnswer = 0;

string strMore =" y",strOperand =" *" ;;


//继续,直到用户输入n

而(strMore ==" y")

{

//获取第一个数字

System.Console.WriteLine(请输入数字);

dblFirstNo =


System.Convert.ToDouble(System.Console.ReadLine());


// as k他们想用数字做什么

System.Console.WriteLine

("请输入一个操作数(* / + -

)");

strOperand =

System.Console.ReadLine();


//获取下一个数字

System.Console.WriteLine(" Please enter another number" );

dblSecondNo =


System.Convert.ToDouble(System.Console.ReadLine());


//确定使用的操作数并执行计算

//这也不理想,但我不知道如何使用

//操作数作为变量并使其作为操作数工作!

if(strOperand ==" *")

{

dblAnswer = dblFirstNo * dblSecondNo;

}

else if(strOperand ==" /")

{

dblAnswer = dblFirstNo / dblSecondNo;

}

else if(strOperand ==" +")

{

dblAnswer = dblFirstNo + dblSecondNo;

}

else if(strOperand ==" - ")

{

dblAnswer = dblFirstNo - dblSecondNo;

}

//输出总和和答案

System.Console.WriteLine

(" {0 } * {1} =

{2}",dblFirstNo,dblSecondNo,dblAnswer);


//询问用户是否要继续

strMore =" z";

while(strMore ==" z")

{

系统。 Console.WriteLine

(你想要

输入更多? (y / n)");

strMore = System.Console.ReadLine();

//检查用户输入的内容

//是Y

if(strMore!=" y")

{

// nope is it n

if(strMore!=" n")

{

//将它设置为z所以


//系统可循环

//允许......不这么认为,


//但它会做到

//我越来越精通

strMore =" z";

}

}

}

}

}
Complete n00b here, so please bear with me.

I have written the following code and would like to know if it could be
optimised. In particular, I''m reading the user input for the operand into
variable strOperand, and rather than use the IF statement to determine which
operand to use, I''d like to use the variable contents
e.g. dblAnswer = dblFirstNo strOperand dblSecondNo

Also, the While clause at the end...ideally, I would like to write something
like
while (strMore != "y" and strMore !="n")

but I don''t know how to do this.

Any help appreciated.
Code ************************************
static void Main(string[] args)
{
//declare the variables to be used with default values
double dblFirstNo = 0, dblSecondNo = 0, dblAnswer = 0;
string strMore = "y", strOperand = "*";

//keep going until the user enters "n"
while (strMore == "y")
{
//get the first number
System.Console.WriteLine("Please enter a number ");
dblFirstNo =

System.Convert.ToDouble(System.Console.ReadLine()) ;

//ask what they want to do with the numbers
System.Console.WriteLine
("Please enter an operand ( * / + -
)");
strOperand =
System.Console.ReadLine();

//get the next number
System.Console.WriteLine("Please enter another number" );
dblSecondNo =

System.Convert.ToDouble(System.Console.ReadLine()) ;

//determine the operand used and perform the calculation
//this isn''t ideal either, but I don''t know how to use
//the operand as a variable and get it to work as an operand!
if (strOperand == "*")
{
dblAnswer = dblFirstNo * dblSecondNo;
}
else if (strOperand == "/")
{
dblAnswer = dblFirstNo / dblSecondNo;
}
else if (strOperand == "+")
{
dblAnswer = dblFirstNo + dblSecondNo;
}
else if (strOperand == "-")
{
dblAnswer = dblFirstNo - dblSecondNo;
}
//output the sum and the answer
System.Console.WriteLine
("{0} * {1} =
{2}",dblFirstNo,dblSecondNo,dblAnswer);

//ask if the user wants to continue
strMore = "z";
while (strMore == "z")
{
System.Console.WriteLine
("Do you want to
enter more? (y/n)");
strMore = System.Console.ReadLine();
//check to see what the user entered
//was it Y
if (strMore != "y")
{
//nope was it n
if (strMore != "n")
{
//set it to z so the

//system can loop
//ideal...don''t think so,

//but it''ll do until
//I get more proficient
strMore = "z";
}
}
}
}
}


这篇关于首先深入研究C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆