1 今天做程序时需要向http协议的get地址中传递一个参数,然后使用string.format格式化,发现一个错误,提示“输入字符串的格式不正确。",语句如下

                string id = "123456";
                string str = string.Format("http://vip.esf.focus.cn/manager.php?do=sale&action=addOn&sale_id={ 0 }&sort=xj&xj=2", id);

本来还以为是C#中的 符号 / 比较特殊,所以在前面加了个@,但是还是不正确,然后就去掉@;

后来想到{0}这个地方容易出错,如果大括号中有空格就报错,因此一定不要在0的两边加空格.

相关文章:

  • 2022-01-02
  • 2022-03-02
  • 2021-09-14
  • 2022-12-23
  • 2022-12-23
  • 2022-01-09
  • 2021-10-23
  • 2022-02-03
猜你喜欢
  • 2021-12-08
  • 2021-11-05
  • 2022-12-23
  • 2021-11-23
  • 2021-08-03
  • 2021-09-03
  • 2021-09-10
相关资源
相似解决方案