输入法 [英] input methods

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

问题描述

 

string myName;
int myVar1,myVar2,myVar3;

Console.WriteLine(" Please enter your name:");
myName =(Console.ReadLine());

Console.WriteLine(" \\\
请输入您的号码");
myVar1 = Convert.ToInt32(Console.ReadLine());

Console.WriteLine(" \\\
请输入你的角色");
myVar2 = Convert.ToInt32(Console.Read());

Console.WriteLine(" \ n输入你的ascii:");
myVar3 =(Console.Read());
char myCharVar =(Char)myVar3;

Console.WriteLine(" \\\
Hello {0}",myName);
Console.WriteLine(" \ n我的号码是{0} \ n我的字符是{1}",myVar1,myVar2);
Console.WriteLine(" my ascii is {0}",myVar3,myCharVar);
Console.ReadKey();



解决方案

什么你想做什么?
b $ b从我看到的我可以告诉你,如果用户没有输入可以转换为该数据类型的东西,比如请求输入数字的字母,我可能会遇到问题。 / p>


string myName; int myVar1, myVar2, myVar3; Console.WriteLine("Please enter your name: "); myName = (Console.ReadLine()); Console.WriteLine("\n Please enter your number"); myVar1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("\n Please enter your character"); myVar2 = Convert.ToInt32(Console.Read()); Console.WriteLine("\n Enter your ascii:"); myVar3 = (Console.Read()); char myCharVar = (Char)myVar3; Console.WriteLine("\n Hello {0}", myName); Console.WriteLine("\n My number is {0}\n My char is {1}",myVar1,myVar2); Console.WriteLine("my ascii is {0}", myVar3,myCharVar); Console.ReadKey();


解决方案

What are you trying to do?
From what I see I can tell you may have issues if the user does not input something that can be cast to that data type like a letter where requested for a number.


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

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