【发布时间】:2015-06-03 19:00:37
【问题描述】:
我快被这个问题发疯了。
我想将 TextView 转换为双格式,但我走的路是运行时错误。
我尝试过的方法:
//first
var enterButton = FindViewById<Button>(Resource.Id.enterGN);
var inPop = FindViewById<EditText>(Resource.Id.inPopulationIn);
var goodPop = FindViewById<EditText>(Resource.Id.goodPopIn);
var yearsNumIn = FindViewById<EditText>(Resource.Id.yearNumIn);
var growingRate =FindViewById<EditText>(Resource.Id.growingRateIn);
int InPop = Int32.Parse(inPop.ToString());
int GoodPop = Int32.Parse(goodPop.ToString());
int YearsNum = Int32.Parse(yearsNumIn.ToString());
double GrowingRate = Int32.Parse(growingRate.ToString());
//second
var enterButton = FindViewById<Button>(Resource.Id.enterGN);
var inPop = FindViewById<EditText>(Resource.Id.inPopulationIn);
var goodPop = FindViewById<EditText>(Resource.Id.goodPopIn);
var yearsNumIn = FindViewById<EditText>(Resource.Id.yearNumIn);
var growingRate =FindViewById<EditText>(Resource.Id.growingRateIn);
string inPops=inpop.ToString();
string ...
int InPop = System.Convert.ToInt32(inPops);
int ....
请帮帮我... 错误在说:
未处理的异常:
System.FormatException: 输入字符串的格式不正确
【问题讨论】:
-
当我进行任何类型的解析时,我都会保持一切不变,例如
double GrowingRate = double.Parse(growingRate.ToString()); -
我修复了它,但问题没有修复它说:未处理的异常:System.FormatException:输入字符串的格式不正确
-
您要转换的字符串的内容是什么?
-
我尝试创建一个计算城市人口增长的应用程序。我需要将所有变量转换为 int 和 double。
标签: c# android casting mono type-conversion