Reputation: 945
The following line gives an error:
Console.WriteLine("Order:{0},\n Placed:{1},\nshipped:{2},\nTo address:{3} ,{4}, {5}\n\n" + orderid, orderdate, shipdate, shipname, shipaddr, shipcity);
It shows an error as:
(Index (zero based) must be greater than or equal to zero an d less than the size of the argument list.)
Help me out to resolve this error. I know this error happened because of the place holder provided are greater than the variables provided.
Upvotes: 0
Views: 107
Reputation: 40002
You have a +
instead of a ,
before your first argument. Correction:
Console.WriteLine("Order:{0},\n Placed:{1},\nshipped:{2},\nTo address:{3} ,{4}, {5}\n\n", orderid, orderdate, shipdate, shipname, shipaddr, shipcity);
The method is therefore only recognising 5 parameters, not 6.
Upvotes: 1
Reputation: 4376
Why do you have a plus at the end of your format string ? This is causing the params to be 5 when the format string expects 6.
Change as below :
Console.WriteLine("Order:{0},\n Placed:{1},\nshipped:{2},\nTo address:{3} ,{4}, {5}\n\n", orderid, orderdate, shipdate, shipname, shipaddr, shipcity);
Upvotes: 1
Reputation:
I'm guessing you wanted:
Console.WriteLine("Order:{0},\n Placed:{1},\nshipped:{2},\nTo address:{3} ,{4}, {5}\n\n", orderid, orderdate, shipdate, shipname, shipaddr, shipcity);
Note the + is not present.
Upvotes: 4
Reputation: 1219
Console.WriteLine("Order:{0},\n Placed:{1},\nshipped:{2},\nTo address:{3} ,{4}, {5}\n\n",orderid, orderdate, shipdate, shipname, shipaddr, shipcity);
should solve the problem.
Upvotes: 2