public string simplifyString(string sInput)
{
if (sInput.Length < 2)
{
return sInput;
}
string sOutput;
int iCount = 0;
for (int i=1; i < sInput.Length; i++)
{
if (sInput[i] != sInput[iCount])
{
iCount++;
sOutput[iCount] = sInput[i];
}
}
return sOutput;
}
The precompiler has a problem with the above C# code.
sOutput[iCount] = sInput[i];
this line has an error. It says that string.this[int] cannot be assigned and is read only.
StringBuilder.sOutput[iCount]returns the character of that index and since strings are immutable, that's normal to be a read only.