Formatting is Specified but argument is not IFormattable

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 Decimal value to String.Format by removing .ToString().

string.Format里面处理的是数字,但是传递了字符串,所以有这个提示

时间: 2024-12-13 12:54:22

Formatting is Specified but argument is not IFormattable的相关文章

21/CLASS - C Language Style for Scalability——ZeroMQ官网建议的C语言命令规范

http://rfc.zeromq.org/spec:21 Table of Contents License Change Process Language Goals Quality Aspirations Common Problems General Style Definitions Language Naming Project Style Project Focus Project Name General Layout Dependencies Project Header Fi

Google C++ 代码规范

Google C++ Style Guide Table of Contents Header Files Self-contained Headers The #define Guard Forward Declarations Inline Functions Names and Order of Includes Scoping Namespaces Unnamed Namespaces and Static Variables Nonmember, Static Member, and

Google C++ Style Guide----英文版

转载请注明出处<http://blog.csdn.net/qianqin_2014/article/details/51354326> Background C++ is the main development language used by many of Google's open-source projects. As every C++ programmer knows, the language has many powerful features, but this power

Supported method argument types Spring MVC

Supported method argument types The following are the supported method arguments: Request or response objects (Servlet API). Choose any specific request or response type, for example ServletRequest or HttpServletRequest. Session object (Servlet API):

String Formatting in C#

原文地址 http://blog.stevex.net/string-formatting-in-csharp/ When I started working with the .NET framework, one thing puzzled me. I couldn’t find sprintf(). sprintf() is the C function that takes an output buffer, a format string, and any number of argu

sed: -i requires an argument Permission denied

在脚本中使用sed时,如果一行的内容较长,为了脚本美观要换行,在行尾添加"\"即可. 注意:如果在"\"之后添加空格,例如: sed -i "/^xxx=/s/.*/xxx=$xxx/"\[:space:]        $xxx echo $? [:space:]表示行尾有一个空格 脚本会报如下错误: sed: -i requires an argument./xxx.sh: line 20: xxx.sh: Permission denied

Name for argument type [java.lang.String] not avai

项目通过MyEclipe部署到Tomcat运行一切OK 使用Jekins,Ant进行管理,部署也OK,但是访问项目时就出现: Name for argument type [java.lang.String] not available, and parameter name information not found in class file either. 参考 http://m.blog.csdn.net/blog/kouwoo/42869779 采用第二种方法最活力,使用Ant编译ja

运维实战案例之“Argument list too long”错误与解决方法

作为一名运维人员来说,这个错误并不陌生,在执行rm.cp.mv等命令时,如果要操作的文件数很多,可能会使用通配符批量处理大量文件,这时就可能会出现"Argument list too long"这个问题了. 1.错误现象 这是一台Mysql数据库服务器,在系统中运行了很多定时任务,今天通过crontab命令又添加了一个计划任务,退出时发生了如下报错: #crontab -e 编辑完成后,保存退出,就出现下面如下图所示错误: 2.解决思路 根据上面报错的提示信息,基本判定是磁盘空间满了,

windows下启动redis提示Invalid argument during startup: Failed to open the .conf file: redis.windows.connf CWD=C:\Users\Administrator

环境:Windows 7 64bit 旗舰版 redis 3.2.100 64bit 开始的时候,redis运行的好好的,不过每次启动都要要进入其路径,挺麻烦的,所以就想把它的路径设置到环境变量里,然后直接运行就出现错误:Invalid argument during startup:Failed to open the .conf file: redis.windows.connf CWD=C:\Users\Administrator 网上搜索了好久也找不到解决办法.后来想是不是因为环境变量的