字符“23.00”转成int型!Input string was not in a correct format.
2012-02-06 17:40
309 查看
如何把字符“23.00”转成int型!
convert,parse,都抱错!
“Input string was not in a correct format.”------解决方案--------------------------------------------------------
如果需要考虑四舍五入可以先转成double
string s= "23.00 ";
double dTemp=double.Parse(s);
int iTemp=Convert.ToInt32(dTemp);
如果不需要,就可以用
string s = "23.00 ";
s = s.Substring(0,s.IndexOf( '. '));
int i = int.Parse(s);
convert,parse,都抱错!
“Input string was not in a correct format.”------解决方案--------------------------------------------------------
如果需要考虑四舍五入可以先转成double
string s= "23.00 ";
double dTemp=double.Parse(s);
int iTemp=Convert.ToInt32(dTemp);
如果不需要,就可以用
string s = "23.00 ";
s = s.Substring(0,s.IndexOf( '. '));
int i = int.Parse(s);
相关文章推荐
- c# 使用 string.format 报错: input string was not in a correct format
- c# - 反序列化报错:Input string was not in a correct format
- Input string was not in a correct format. 错误解析
- Error:The method setInputPaths(JobConf, String) in the type FileInputFormat is not
- not recognize input near 'row' 'format' 'delimited' in select clause
- Xcode 警告信息处理:Format string is not a string literal (potentially insecure)
- The following URL schemes found in your app are not in the correct format 解决方案
- linux ubuntu 下 ‘string’ was not declared in this scope 解析
- not recognize input near 'row' 'format' 'delimited' in select clause
- not recognize input near 'row' 'format' 'delimited' in select clause
- 编译opencv 2.4.13error:1 /usr/include/string.h:652:42: error: ‘memcpy’ was not declared in this scope
- 经典问题---'cout' /string was not declared in this scope
- not recognize input near 'row' 'format' 'delimited' in select clause
- 不可见字符会引起的java.lang.NumberFormatException: For input string: "15"
- not recognize input near 'row' 'format' 'delimited' in select clause
- 异常-----Can't convert the date to string, because it is not known which parts of the date variable are in use. Use ?date, ?time or ?datetime built-in, or ?string.\u003Cformat> or ?string(format) built-
- not recognize input near 'row' 'format' 'delimited' in select clause
- A file with the correct name was found in this directory, but it is not the correct one.
- not recognize input near 'row' 'format' 'delimited' in select clause
- not recognize input near 'row' 'format' 'delimited' in select clause