String.Format可以正确地处理字符串数组,但在处理整数数组时会出现以下异常:
索引(从零开始)必须大于或等于零,并且小于参数列表的大小。
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.
为什么会这样呢?