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 represents a whitespace character?
I would like to do something like this:
test.ToLower().Split(string.Whitespace)
//test.ToLower().Split(Char.Whitespace)
This question is related to
c#
Using regular expressions, you can represent any whitespace character with the metacharacter "\s"
You can always use Unicode character, for me personally this is the most clear solution:
var space = "\u0020"
Which whitespace character? The most common is the normal space, which is between each word in my sentences. This is just " "
.
No, there isn't such constant.
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));
Source: Stackoverflow.com