Reputation:
Can anyone say me why when using this block of code :
StringBuilder temp = new StringBuilder(strSource);
for (int i = Start; i <= End-1; i++)
{
temp[i] = '';
}
I get an error in the "for" loop: literal empty character.
On the other hand, this works:
temp[i] = ' ';
Upvotes: 0
Views: 118
Reputation: 51330
You're trying to reinvent the Remove
method:
if (End > Start)
temp.Remove(Start, End - Start);
''
is not valid because single quotes introduce a char
literal, which must always be one char
.
Upvotes: 3
Reputation: 887365
Characters must have a value.
Instead, you should write
temp.Length = 0;
Upvotes: 0