문제

How can I output Windows Alt key codes to the console in a C# console app using Console.WriteLine()?

I would like to output characters such as those used for creating boxes. I can do so manually in a command prompt by holding alt and typing in the appropriate number such as Alt+205, Alt+187, etc.

Thanks

도움이 되었습니까?

해결책

I suppose the easiest way would be to include them directly in your string literals within your source code:

Console.WriteLine("═╗");

다른 팁

EDIT: I'm sorry - my answer is incorrect. ASCII.GetChars will not work for extended ASCII characters. Thanks to Douglas for correcting me.


I think Douglas's answer is the most direct, but you could also get the character based on the value directly using something like this:

char[] characters = System.Text.Encoding.ASCII.GetChars(new byte[] {65});

For whatever ASCII code you wanted.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top