Set a character with WhiteSpace −
char c = ' ';
To check if a character is a whitespace character, use the char.IsWhiteSpace method −
if (char.IsWhiteSpace(c)) {}Let us see the complete code −
Example
using System;
class Demo {
static void Main() {
char c = ' ';
if (char.IsWhiteSpace(c)) {
Console.WriteLine("Whitespace character!");
}
}
}Output
Whitespace character!