Reputation: 1325
public override string ToString()
{
string val;
if (blower)
val = "Yes";
else
val = "No";
return string.Format(
"With Blower \t:\t {0} \n" +
val);
}
I am getting an exception in these lines:-
return string.Format(
"With Blower \t:\t {0} \n" +
val);
The exception is:
Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
What am I doing wrong?
Upvotes: 0
Views: 197
Reputation: 1804
You could simplify this entire method:
public override string ToString()
{
return string.Format("With Blower \t:\t {0} \n", blower ? "Yes" : "No");
}
Upvotes: 3
Reputation: 3439
Use comma instead of concatenation
return string.Format("With Blower \t:\t {0} \n", val);
Upvotes: 0
Reputation: 3586
Try separating by a comma:
return string.Format( "With Blower \t:\t {0} \n", val);
Upvotes: 1
Reputation: 25445
I think you meant
return string.Format("With Blower \t:\t {0} \n", val);
^
Upvotes: 10
Reputation: 3417
I think you need to replace the + with a comma maybe:
return string.Format(
"With Blower \t:\t {0} \n",
val);
Upvotes: 1