How shall i add control character to string
int stxval = 0x02; //found this value on wikipedia
string mystring = "Hello";
StringBuilder builder = new StringBuilder(开发者_C百科mystring);
builder.Append(stxval);
Here in string builder "2Hello"
is appended. how to get string in this form "Hello"?
Use char
instead:
char stx = '\u0002';
or
char stx = (char) 2;
Personally I prefer the first option, but it's up to you.
Anyway, then just use:
StringBuilder builder = new StringBuilder(mystring);
builder.Append(stx);
builder.Append((char)stxval);
else it will just add int.ToString()
精彩评论