0

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.

1
  • 1
    Check your syntax... you put a '+' instead a ',' to provide 6 arguments. Commented Jan 25, 2013 at 7:20

4 Answers 4

4

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.

Sign up to request clarification or add additional context in comments.

Comments

2
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.

2 Comments

Actually ryadavilli was the first to answer.
Thanks Peter Huene. What matters most to me is that Gomathipriya has found answer to the query. :)
1

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);

Comments

1

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.

1 Comment

I think you mean "The method is therefore only recognising 5 parameters, not 6."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.