private int FindNumber(string sPar)
{
// Get the last number
int len = sPar.Length;
string s = sPar.Substring(len-1);
return new (int)Decimal(s);
}
在这里我得到了错误;必需的 。任何人都可以帮我解决这个问题。
谢谢!
最佳答案
将您的代码更改为:
private int FindNumber(string sPar)
{
int len = sPar.Length;
string s = sPar.Substring(len - 1);
return Convert.ToInt32(s);
}
或者,更短:
private int FindNumber(string sPar)
{
return Convert.ToInt32(sPar.Substring(sPar.Length - 1));
}
关于c# - 在 C# 中使用小数进行转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3967717/