How to correctly represent a whitespace character

后端 未结 6 1391
醉酒成梦
醉酒成梦 2020-12-15 16:31

I wanted to know how to represent a whitespace character in C#. I found the empty string representation string.Empty. Is there anything like that that represent

6条回答
  •  既然无缘
    2020-12-15 16:48

    The WhiteSpace CHAR can be referenced using ASCII Codes here. And Character# 32 represents a white space, Therefore:

    char space = (char)32;
    

    For example, you can use this approach to produce desired number of white spaces anywhere you want:

    int _length = {desired number of white spaces}
    string.Empty.PadRight(_length, (char)32));
    

提交回复
热议问题