gpt4 book ai didi

c# - 为什么 String.Format 会产生歧视?

转载 作者:行者123 更新时间:2023-11-30 13:31:40 26 4
gpt4 key购买 nike

<分区>

String.Format 可以愉快地处理字符串数组,但在处理整数数组时会出现异常:

Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

        string result = null;
var words = new string[] { "1", "2", "3" };
result = String.Format("Count {0}{1}{2}", words); //This works.

var nums = new int[] { 1, 2, 3 };
result = String.Format("Count {0}{1}{2}", nums); //This throws an exception.

为什么会这样?

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com