C# | Char.IsWhiteSpace() Method - GeeksforGeeks

31 Jan, 2019
In C#, Char.IsWhiteSpace() is a System.Char struct method which is used to check whether a Unicode character is a whitespace or not. Whitespace characters include Unicode characters of category SpaceSeparator, LineSeparator, ParagraphSeparator etc. This method can be overloaded by passing different type and number of arguments to it.
Char.IsWhiteSpace(Char) MethodChar.IsWhiteSpace (String, Int32) Method
Char.IsWhiteSpace(Char) Method
Char.IsWhiteSpace (String, Int32) Method
This method is used to check whether a specified Unicode character can be categorized as a whitespace character or not. If it can be categorized as whitespace then it returns True otherwise return False.
Syntax:
public static bool IsWhiteSpace(char ch);
Parameter:
ch: It is required Unicode character of System.char type which is to be checked for whitespace.
Return Type : The method returns True if the specified Unicode character is a whitespace character, otherwise returns False. The return type of this method is System.Boolean.
Example:
// C# program to illustrate the// Char.IsWhiteSpace(Char) Methodusing System;  class GFG {      // Main Method    static public void Main()    {          // Declaration of data type        bool result;          // checking if space        // is a whitespace        char ch1 = ' ';        result = Char.IsWhiteSpace(ch1);        Console.WriteLine(result);          // checking if carriage return        // is a whitespace        char ch2 = '\n';        result = Char.IsWhiteSpace(ch2);        Console.WriteLine(result);          // checking if hyphen        // is a whitespace        char ch3 = '-';        result = Char.IsWhiteSpace(ch3);        Console.WriteLine(result);    }}
True
True
False

This method is used to check whether a character in the specified string at the specified position can be categorized as whitespace or not. It returns True when the character is a whitespace character otherwise it returns False.
Syntax:
public static bool Char.IsWhiteSpace(string str, int index);
Parameters:
Str: It is the required string of System.String type whose character is to be checked.index: It is the position of character in the specified string and type of this parameter is System.Int32.
Return Type: The method returns True if the character at specified index in the specified string can be categorized as whitespace, otherwise returns False. The return type of this method is System.Boolean.
Example:
// C# program to illustrate the// Char.IsWhiteSpace (String, Int32) Methodusing System;  class GFG {      // Main Method    static public void Main()    {          // Declaration of data type        bool result;          // checking for whitespace        // in a string        string str1 = "GeeksforGeeks";        result = Char.IsWhiteSpace(str1, 2);        Console.WriteLine(result);          // checking for whitespace        // in a string        string str2 = "Geeks For Geeks";        result = Char.IsWhiteSpace(str2, 5);        Console.WriteLine(result);    }}
False
True

Reference: https://docs.microsoft.com/en-us/dotnet/api/system.char.iswhitespace?view=netframework-4.7.2
CSharp-Char-Struct
CSharp-method
C#
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Difference between Abstract Class and Interface in C#
C# | How to check whether a List contains a specified element
C# | IsNullOrEmpty() Method
String.Split() Method in C# with Examples
C# Dictionary with examples
C# | Method Overriding
C# | Arrays of Strings
C# | Delegates
Difference between Ref and Out keywords in C#
Destructors in C#