本文介绍了控制台应用,c#输入值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有人可以告诉我如何从键盘中给出值不是静态的应用程序,这是代码的一部分,这里是值静态的:
does any one can tell me how to give the value from keyboard not to be static in application, this is the part of code here is value static:
var city = new city(5);这是一个类
and this is a class
class city { private readonly int[] _num; private readonly int _size; public city(int Size) { _size = Size; _num= new int[_size]; }这只是为了让你适应代码....这个数字在新的城市(5) 。我想从tast进入,但我不能......
this is just to adapt you with code.... this number that is in new city(5). I want to enter from tast,,but I cant...
推荐答案试试这个: Hi, Try this: int cityInt = -1; try { cityInt = Convert.ToInt32(Console.ReadLine()); } catch { Console.WriteLine("Input isn't an integer!"); } if (cityInt != -1) { var city = new city(cityInt); }
希望这有帮助。
Hope this helps.
更多推荐
控制台应用,c#输入值
发布评论