Formatting is Specified but argument is not IFormattable
private void DeviceSetText(TextBox textBox, string text)
{
//处理text的显示值
if (text != "") //小数位后保留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 Decimal value to String.Format by removing .ToString().
string.Format里面处理的是数字,但是传递了字符串,所以有这个提示
Formatting is Specified but argument is not IFormattable的更多相关文章
- 使用Built-in formatting来创建log字符串
在一次哦测试中,sonar-qube总是报Use the built-in formatting to contruct this argument, 在网上查了一下,原来它是推荐这样做: log.i ...
- Google C++ Style Guide
Background C++ is one of the main development languages used by many of Google's open-source project ...
- Google C++ 代码规范
Google C++ Style Guide Table of Contents Header Files Self-contained Headers The #define Guard For ...
- python 之 string() 模块
common string oprationsimport string1. string constants(常量) 1) string.ascii_letters The concat ...
- 02 Go 1.2 Release Notes
Go 1.2 Release Notes Introduction to Go 1.2 Changes to the language Use of nil Three-index slices Ch ...
- lombok插件/slf4j中字符串格式化
大家在编写springboot项目的过程中可能会接触到lombok这个插件,这个插件可以在编译时帮我生成很多代码. 1.@Data生成Getter和Setter代码,用于类名注释 2.@Getter ...
- Supported method argument types Spring MVC
Supported method argument types The following are the supported method arguments: Request or respons ...
- String Formatting in C#
原文地址 http://blog.stevex.net/string-formatting-in-csharp/ When I started working with the .NET framew ...
- CSS学习笔记——视觉格式化模型 visual formatting model
CSS 视觉格式化模型(visual formatting model)是用来处理文档并将它显示在视觉媒体上的机制.他有一套既定的规则(也就是W3C规范),规定了浏览器该怎么处理每一个盒子.以下内容翻 ...
随机推荐
- Java多线程间通信-解决安全问题、等待唤醒机制
/*1.增加一个知识点一个类怎么在所有的类中,让其它类来共同修改它的数据呢?可以用单例设计模式可以用静态可以在其它类中做一个构造函数,接受同一个对象,这样就可以实现对象 2.状态选择可以用数字0 1 ...
- ceilometer
控制节点: ceilometer-api: /etc/init.d/openstack-ceilometer-api status ceilometer-collector /etc/init.d/ ...
- 九度OJ 1547 出入栈 -- 动态规划
题目地址:http://ac.jobdu.com/problem.php?pid=1547 题目描述: 给定一个初始为空的栈,和n个操作组成的操作序列,每个操作只可能是出栈或者入栈. 要求在操作序列的 ...
- jQuery 扩展 【ajax实例】
先前写工具类都是自定义类,直接prototype,jQuery扩展这一块儿,一直也没写过,刚好今天有空,写个试试. 已经有很多人对jQuery,jQuery.fn,jQuery.fn.extend详细 ...
- SQL技巧之排名统计
有一道SQL笔试题是这样子的: 已知表信息如下: Department(depID, depName),depID 系编号,DepName系名 Student(stuID, name, depID) ...
- 远程连接Ucenter数据库
网站和Ucenter不是同一服务器的连接方法~我折腾了好几天,终于找到了这方法!各位连接不上的不妨试试~什么事只有试过才知道行不行! define('UC_CONNECT', 'mysql'); de ...
- Demo学习: CalendarPanel
CalendarPane 学习CalendarPanel控件的常用事件. DayClick(...) //点击日期块空白部分触发EventClick(...) //点击日期块上事件触发RangeSel ...
- 将TIBCO Host 实例注册为Windows服务
安装了TIBCO ActiveMatrix BPM及成功创建了ActiveMatrix Administrator 和 BPM Server后,每次都要手动启动tibcohost,比较麻烦,实际上TI ...
- ibatis访问oracle数据库US7ASCII中文乱码问题
今天碰到一个问题,使用ibatis框架访问编码为US7ASCII的oracle数据中文乱码, 找了很久终于有了解决方案 首先 SqlMap-Config.xml按如下配置 <sqlMapConf ...
- VC项目配置基础以及快捷键(收藏)
来自http://blog.csdn.net/phunxm/article/details/5082488 一.IDE基础配置 1.字体 VC6中“Tools→Options→Format→Font” ...