开发者

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()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜