简体   繁体   中英

casting char for ansi characters

I'm migrating a project from VB6 to C#.

In one part of the code it gets the int value in ANSI(I think!) and gets the char value to an string:

StringBuilder s_e = new StringBuilder();
s_e.Append(Microsoft.VisualBasic.Strings.Chr(inNCr).ToString());

Tried with

s_e.Append((char)inNCr);

But works only from az but not for another characters, so the result is not always correct.

I know I can use using Microsoft.VisualBasic; and be done with it, but is there any way to do it "natively" in c#?

Thanks in advance.

[edit] Clarification needed.

inNCr is the character code of the character as an int. then that int should be a char and show up as an string on the app. For example: Character code 130 should be '‚' but on the app is showing as blank and on debug as \‚

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM