Formatting is Specified but argument is not IFormattable
2015-09-22 09:49
573 查看
private void DeviceSetText(TextBox textBox, string text) { //处理text的显示值 if (text != "0") //小数位后保留2位 { //小数点后保留2位小数 text = string.Format("{0:0.00}", text); } textBox.Invoke((MethodInvoker) delegate { textBox.Text = text; }); }
text = string.Format("{0:0.00}", text);
和下面的问题类似
http://stackoverflow.com/questions/2849688/formatting-is-specified-but-argument-is-not-iformattable
string listOfItemPrices = items.ToSemiColonList(item => string.Format("{0:C}", item.Price.ToString()));
By passing
item.Price.ToString()to
String.Format, you are passing a string, not a decimal.
Since strings cannot be used with format strings, you're getting an error.
You need to pass the
Decimalvalue to
String.Formatby removing
.ToString().
string.Format里面处理的是数字,但是传递了字符串,所以有这个提示
相关文章推荐
- 多条记录的同一字段组合成一个字符串 FOR XML PATH
- 9.22问题总结
- LeetCode -- Basic Caculator
- 【TCP】TCP连接建立过程的三次握手
- URAL 1009 K-based Numbers (DP动态规划)
- 线性表
- jQuery权限控制
- Centos6.x PPTPD 搭建方法,亲测有效
- HDU 3648 Median Filter
- 【转】C# 流总结
- 解决更新Xcode以后使用Git报错的问题
- js 让小数四舍五入保留两位小数的函数是?
- 玩node-images模块---Node.js轻量级跨平台图像编解码库
- Android开发总结笔记 TableLayout(表格布局) 1-1-4
- less的使用
- SetTimer时间函数
- iOS9 适配
- SRM 668 DIV 2 VerySecureEncryption 250point
- mongodb执行js脚本
- Cordova插件