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规范),规定了浏览器该怎么处理每一个盒子.以下内容翻 ...
随机推荐
- asp.net 备份和恢复数据库
观看了Insus的视频写下来的,代码可能有点冗长,如有好的想法的,可以多交流. 前台: <form id="form1" runat="server"&g ...
- 轮子来袭 vJine.Core Orm 之 01_快速体验
vJine.Core 是.Net环境下C#类库,在其包含的众多功能中ORM功能尤为突出,现简介如下. 一.支持的数据库: SQLite, MySQL, MS SQL, Oracle. 二.使用方法: ...
- Java的基本数据类型
java的基本数据类型是四类八种: 整型 byte 1字节 8位 short 2字节 16位 int 4字节 32位 long 8字节 64位 在hibernate自动映射中会根据数字长度,选 ...
- T-SQL
今天继续数据库知识的梳理.接下来的主要内容是T-SQL,针对的数据库是SQL Server 2008. 几个术语 数据定义语言(DDL,Data Definition Language):用来建立数据 ...
- linux中 ECShop的文件不能写
解决办法: 1.开放权限 使用命令:chmod -R 777 文件路径 2.关闭SELinux 使用命令:setenforce 0
- HaProxy+keepalived实现负载均衡
HAProxy提供高可用性.负载均衡以及基于TCP和HTTP应用的代理,支持虚拟主机,它是免费.快速并且可靠的一种解决方案.HAProxy特别适用于那些负载特大的web站点,这些站点通常又需要会话保持 ...
- html5新增标签兼容性
很多低版本的浏览器是不识html5新增的标签的,所以为了解决浏览器兼容性问题,主要有两种方法: js可以创建我们自定义的标签,例如,我们可以用js语句 document.createElement(' ...
- 【转】SQL2008清除日志
USE [master] GO ALTER DATABASE DNName SET RECOVERY SIMPLE WITH NO_WAIT GO ALTER DATABASE DNName SET ...
- select框默认样式去除(ie中隐藏默认下拉图标)
html代码 <select class="info-select"> <option selected="selected">1< ...
- 三个PHP常用代码样例
作为一个正常的程序员,会好几种语言是十分正常的,相信大部分程序员也都会编写几句PHP程序,如果是WEB程序员,PHP一定是必备的.尽管PHP经常被人诟病,被人贬低,被人当玩笑开,事实证明,PHP是全世 ...