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的更多相关文章

  1. 关于System.FormatException异常

    什么是FormatException 参数格式无效或复合格式字符串不正确时引发的异常. 继承 Object Exception SystemException FormatException 详细说明 ...

  2. “System.FormatException”类型的未经处理的异常在 System.IdentityModel.dll 中发生 其他信息: 十六进制字符串格式无效。

    如果你的 WebService 客户端证书配置都没问题,唯独调用接口会出现这个错误 “System.FormatException”类型的未经处理的异常在 System.IdentityModel.d ...

  3. C# winform单元格的formatted值的类型错误 DataGridView中CheckBox列运行时候System.FormatException异常

    在DataGridView手动添加了CheckBox列;在窗体Show的时候,遇到一个错误:错误如下: DataGridView中发生一下异常:System.FormatException:单元格的F ...

  4. DataGridView 中发生以下异常: System.Exception: 是 不是 Decimal 的有效值。 ---> System.FormatException: 输入字符串的格式不正确。

    其实之前我自己是没测出这个问题的,但是一放到测试的手上就出来了,原因我知道在哪里改输什么东西,但是人家不知道啊.报错如下: --------------------------- “DataGridV ...

  5. Notes on Distributed System -- Distributed Hash Table Based On Chord

    task: 基于Chord实现一个Hash Table 我负责写Node,队友写SuperNode和Client.总体参考paper[Stoica et al., 2001]上的伪代码 FindSuc ...

  6. System.FormatException: GUID 应包含带 4 个短划线的 32 位数(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。

    在NHibernate数据库查询中出现了这个错误,由于是数据库是mysql的,当定义的字段为char(36)的时候就会出现这个错误. [解决方法] 将char(36) 改成varchar(40)就行了 ...

  7. “System.FormatException”类型的异常在 mscorlib.dll 中发生,但未在用户代码中进行处理 其他信息: 该字符串未被识别为有效的 DateTime。

    前台用过jquery ajax将值传递到 后台的一般处理程序 并且报了这个异常 原因是:前台传递过来的时间格式不对  需要把 "/"换成 "-"   例如:20 ...

  8. System.FormatException: GUID 应包含带 4 个短划线的 32 位数(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)。解决办法

    查一下数据库的UID数据是否格式正确,如: 错误格式1: {E056BB36-D824-4106-A9C3-D8D8B9ADC1C 错误格式2: E056BB36-D824-4106-A9C3-D8D ...

  9. SqlBulkCopy插入时:来自数据源的 String 类型的给定值不能转换为指定目标列的类型 int。 ---> System.FormatException: 将参数值从 String 转换到 Int32 失败。 ---> System.FormatException: 输入字符串的格式不正确。

    偶尔间看到的 记录下:https://bbs.csdn.net/topics/390430064

随机推荐

  1. JS从头开始

    API:应用程序编程接口 HTML:超文本标记语言 XML:可扩展标记语言 HTML和XML的差别:设计目的不同:XML被设计用来传输和存储数据,其焦点在数据的内容:HTML被设计用来显示数据,其焦点 ...

  2. ListView滚动到顶部

    videoAdapter.notifyDataSetChanged();videoListView.setSelection(0); 注意顺序先notify后setSelection

  3. tyvj1015 - 公路乘车 ——完全背包

    题目链接:https://www.tyvj.cn/Problem_Show.aspx?id=1015 完全背包 #include <cstdio> #include <algorit ...

  4. UVa 1592 数据库(c++pair)

    Input Input contains several datasets. The first line of each dataset contains two integer numbersn  ...

  5. leetcode 118 Pascal's Triangle ----- java

    Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,Retur ...

  6. UVA-11468 Substring(AC自动机+DP)

    题目大意:给一些模板串,一些字符的出现概率.问不会出现模板串的概率是多少. 题目分析:是比较简单的概率DP+AC自动机.利用全概率公式递推即可. 代码如下: # include<iostream ...

  7. 在div中设置文字与内部div垂直居中

    要实现如图一所示的结果: html代码如下: <!DOCTYPE html> <html> <head lang="zh"> <meta ...

  8. IIS用户权限备忘

    经常在网站部署到IIS遇到IIS帐户没有权限的问题,总是在看IIS Admin Service,但发现些帐户是有权限的. 其实针对相应的站点,应该看的是Application Pool的运行帐户,这个 ...

  9. share point 读取 List数据

    SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite oSite = new SPSite(siteUrl)) { forea ...

  10. 005. asp.net页面常用指令

    页面指令 用于通知编译器在编译该页面时做出什么样的处理方式, 欢聚换来讲, 页面指令指定了执行该页面的运行时环境, 当编译器处理应用程序时, 可以通过这些指令来让编译器做特定的处理;  在asp.ne ...