I encountered some exceptions from bizzar when building the connection string in my application.
string basis = "Data Source={0};Initial Catalog={1};Persist Security Info={2};User ID={3};Password={4}";
List<string> info1 = new List<string>(){ "SQLSRV", "TEST", "True", "user1", "pass1" };
string[] info2 = new string[] { "SQLSRV", "TEST", "True", "user1", "pass1" };
Console.WriteLine(String.Format(basis, info1));
Console.WriteLine(String.Format(basis, info2));
Error:
An unhandled exception of type "System.FormatException" occurred in mscorlib.dll
Additional information: an index (based on zero) must be greater than or equal to zero and less than the size of the argument list.
My question is: what happened to the List index?
source
share