T
travis powell
i have created a string class. later on i created a procedure where i
need to change charaters in the string. it seems to work just fine unitl
i want to assigm the new character values to a particular position in
the string [see starred lines at the bottom]. i get the error message
that the Property or Indexer is Read-only on compile. can anyone see
where i am going wrong? thanks in advance.
public class InputString
{
private string strParseString;
// A read-write instance property:
public string InStr
{
get
{
return strParseString;
}
set
{
strParseString = value;
}
}
}
public void CharaChange(string ssInStr, int nnInPos, int nnCnt)
{
char strTmp1;
char strTmp2;
InputString strCharaChange = new InputString();
strCharaChange.InStr = ssInStr;
strTmp1 = strCharaChange.InStr[nnInPos];
strTmp2 = strCharaChange.InStr[nnCnt];
strCharaChange.InStr[nnInPos] = strTmp2; //*******************
strCharaChange.InStr[nnCnt] = strTmp1; //*******************
}
need to change charaters in the string. it seems to work just fine unitl
i want to assigm the new character values to a particular position in
the string [see starred lines at the bottom]. i get the error message
that the Property or Indexer is Read-only on compile. can anyone see
where i am going wrong? thanks in advance.
public class InputString
{
private string strParseString;
// A read-write instance property:
public string InStr
{
get
{
return strParseString;
}
set
{
strParseString = value;
}
}
}
public void CharaChange(string ssInStr, int nnInPos, int nnCnt)
{
char strTmp1;
char strTmp2;
InputString strCharaChange = new InputString();
strCharaChange.InStr = ssInStr;
strTmp1 = strCharaChange.InStr[nnInPos];
strTmp2 = strCharaChange.InStr[nnCnt];
strCharaChange.InStr[nnInPos] = strTmp2; //*******************
strCharaChange.InStr[nnCnt] = strTmp1; //*******************
}