Getting the error as "Only assignment, call, increment, decrement ....." [Resolved]

Posted by Allemahesh under C# on 7/25/2013 | Points: 10 | Views : 4340 | Status : [Member] [MVP] | Replies : 1
I am using the below code:-

for (int i = 0; i < str.Length; i + 2)
{
sb.Append(str.Substring(i, 2));
}

I am getting the below error:-
"Only assignment, call, increment, decrement, and new object expressions can be used as a statement"

Can any one help me.




Responses

Posted by: Jeyanthi on: 7/25/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi,

Can you try i +=2 instead of i+2 in the below loop
for (int i = 0; i < str.Length; i += 2)
{
sb.Append(str.Substring(i, 2));
}

Regards,
Jeyanthi

Allemahesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response