且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我如何在C#中所有可打印字符列表?

更新时间:2023-11-08 15:39:04

这会给你不被视为控制字符的所有字符的列表:

This will give you a list with all characters that are not considered control characters:

List<Char> printableChars = new List<char>();
for (int i = char.MinValue; i <= char.MaxValue; i++)
{
    char c = Convert.ToChar(i);
    if (!char.IsControl(c))
    {
        printableChars.Add(c);
    }
}

您可能需要调查其他的Char.IsXxxx 方法,找到适合您需求的组合。

You may want to investigate the other Char.IsXxxx methods to find a combination that suits your requirements.