System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list
static void Main(string[] args)
{
StringBuilder sb = new StringBuilder();
string test = "124454664{0}89jnhb";
string formattedMessage = string.Format(test, args); }
主要原因是字符串中有{}, 被string.Format调用时报错。
Replace即可。
StringBuilder sb = new StringBuilder();
string test = "124454664{0}89jnhb";
test = test.Replace("{", "[").Replace("}", "]");
string formattedMessage = string.Format(test, args);
或者 将 { 替换为 {{
System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list的更多相关文章
- 关于System.FormatException异常
什么是FormatException 参数格式无效或复合格式字符串不正确时引发的异常. 继承 Object Exception SystemException FormatException 详细说明 ...
- “System.FormatException”类型的未经处理的异常在 System.IdentityModel.dll 中发生 其他信息: 十六进制字符串格式无效。
如果你的 WebService 客户端证书配置都没问题,唯独调用接口会出现这个错误 “System.FormatException”类型的未经处理的异常在 System.IdentityModel.d ...
- C# winform单元格的formatted值的类型错误 DataGridView中CheckBox列运行时候System.FormatException异常
在DataGridView手动添加了CheckBox列;在窗体Show的时候,遇到一个错误:错误如下: DataGridView中发生一下异常:System.FormatException:单元格的F ...
- DataGridView 中发生以下异常: System.Exception: 是 不是 Decimal 的有效值。 ---> System.FormatException: 输入字符串的格式不正确。
其实之前我自己是没测出这个问题的,但是一放到测试的手上就出来了,原因我知道在哪里改输什么东西,但是人家不知道啊.报错如下: --------------------------- “DataGridV ...
- Notes on Distributed System -- Distributed Hash Table Based On Chord
task: 基于Chord实现一个Hash Table 我负责写Node,队友写SuperNode和Client.总体参考paper[Stoica et al., 2001]上的伪代码 FindSuc ...
- System.FormatException: GUID 应包含带 4 个短划线的 32 位数(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。
在NHibernate数据库查询中出现了这个错误,由于是数据库是mysql的,当定义的字段为char(36)的时候就会出现这个错误. [解决方法] 将char(36) 改成varchar(40)就行了 ...
- “System.FormatException”类型的异常在 mscorlib.dll 中发生,但未在用户代码中进行处理 其他信息: 该字符串未被识别为有效的 DateTime。
前台用过jquery ajax将值传递到 后台的一般处理程序 并且报了这个异常 原因是:前台传递过来的时间格式不对 需要把 "/"换成 "-" 例如:20 ...
- System.FormatException: GUID 应包含带 4 个短划线的 32 位数(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。解决办法
查一下数据库的UID数据是否格式正确,如: 错误格式1: {E056BB36-D824-4106-A9C3-D8D8B9ADC1C 错误格式2: E056BB36-D824-4106-A9C3-D8D ...
- SqlBulkCopy插入时:来自数据源的 String 类型的给定值不能转换为指定目标列的类型 int。 ---> System.FormatException: 将参数值从 String 转换到 Int32 失败。 ---> System.FormatException: 输入字符串的格式不正确。
偶尔间看到的 记录下:https://bbs.csdn.net/topics/390430064
随机推荐
- php文件遍历类:FileBianli.class.php
<?php class FileBianli{ private $dirname; private $dirsize=0; private $totalsize=0;//当前目录大小 funct ...
- Android TouchEvent事件传递机制
本文转载自:http://blog.csdn.net/morgan_xww/article/details/9372285 跟touch事件相关的3个方法: public boolean dispat ...
- 查找目录下的所有文件中是否含有某个字符串 linux
查找目录下的所有文件中是否含有某个字符串 find .|xargs grep -ri "IBM" 查找目录下的所有文件中是否含有某个字符串,并且只打印出文件名 find .|xar ...
- 3D知识补充
Light Mapping = Dark Mapping (光照映射.黑暗映射) 本质上也是多贴一张图,他是做相乘操作.第2张纹理通常中间亮,外面暗.如果是简单的 Modulate,那么实际上所有像素 ...
- orzdba的安装与使用
参考:http://code.taobao.org/p/orzdba/src/ http://code.taobao.org/p/myrelay/wiki/index/ http://www.taob ...
- Nginx反向代理讲解和配置
首先来介绍下Nginx的反向代理.代理服务器一般分为正向代理(通常直接称为代理服务器)和反向代理. 画个图我们就好理解了. 正向代理:可以想象成是路由器,我们要通过它来上网的那种.(可以说是客户端的代 ...
- SQL存储过程相关信息查看转
原文地址:http://www.cnblogs.com/minideas/archive/2009/10/29/1591891.html --1.查看所有存储过程与函数 exec sp_ ...
- unity, eulerAngle
unity中欧拉角规定如下: A rotation that rotates euler.z degrees around the z axis, euler.x degrees around the ...
- lambda 的使用汇总
d=lambda x:x+1print(d(10))lambda 相当于一个轻量函数返回 d=lambda x:x+1 if x>0 else "error"print(d( ...
- 从K近邻算法谈到KD树、SIFT+BBF算法
转自 http://blog.csdn.net/v_july_v/article/details/8203674 ,感谢july的辛勤劳动 前言 前两日,在微博上说:“到今天为止,我至少亏欠了3篇文章 ...