For expediency sake, I have implemented the following code:
private char[] ReturnDelimiter(string strDelimiter)
{
char[] achrDelimiter;
switch(strDelimiter)
{
case "\r":
achrDelimiter = new char[]{'\r'};
break;
case "\n":
achrDelimiter = new char[]{'\n'};
break;
case "\r\n":
achrDelimiter = new char[]{'\r','\n'};
break;
case "\t":
achrDelimiter = new char[]{'\t'};
break;
default:
achrDelimiter = strDelimiter.ToCharArray();
break;
}
return achrDelimiter;
}
But I'd still like to know if there is a better way to do this.
Especially if it can be read in as an escape sequence from the file
during serialization.
Cheers
Russ
Dinsdale wrote:
I have an xml file that is read into an object using serialization. One
of the objects has a string field called delimeter that I want to
contain a carriage return. Instead of trying to include the carriage
return, I used "\r" thinking that when it was read back into the object
it would be interpreted as a carriage return. Instead, I am getting the
string literal instead of the escape sequence. Does anybody have a
slick way of telling it to return a carriage return? I'd rather not
have to use special cases for escape characters, but I will if
necessary.
Cheers!
Russ