Char.IsWhiteSpace Method

Definition

指示 Unicode 字符是否属于空格类别。Indicates whether a Unicode character is categorized as white space.

Overloads

IsWhiteSpace(Char)

指示指定的 Unicode 字符是否属于空格类别。Indicates whether the specified Unicode character is categorized as white space.

IsWhiteSpace(String, Int32)

指示指定字符串中位于指定位置处的字符是否属于空格类别。Indicates whether the character at the specified position in a specified string is categorized as white space.

Remarks

空白字符是以下 Unicode 字符:White space characters are the following Unicode characters:

  • UnicodeCategory.SpaceSeparator 类别的成员,包括字符空间(U + 0020)、无间断空格(U + 00A0)、欧甘空格标记(U + 1680)、EN 四(U + 2000)、EM 四(U + 2001)、半角空格(u + 2002)、EM 空间(U + 2003)、每半 em 空间(u + 2004)、四个每 EM 空格(u + 2005)、六个每全身空间(U + 2006)、图 SPACE (U + 2007)、标点空间(u + 2008)、细空间(U + 2009)、头发空间(U + 200A)、窄无间断空格(u + 202F)、中数学空间(u + 205F)和表意空间(U + 3000)。Members of the UnicodeCategory.SpaceSeparator category, which includes the characters SPACE (U+0020), NO-BREAK SPACE (U+00A0), OGHAM SPACE MARK (U+1680), EN QUAD (U+2000), EM QUAD (U+2001), EN SPACE (U+2002), EM SPACE (U+2003), THREE-PER-EM SPACE (U+2004), FOUR-PER-EM SPACE (U+2005), SIX-PER-EM SPACE (U+2006), FIGURE SPACE (U+2007), PUNCTUATION SPACE (U+2008), THIN SPACE (U+2009), HAIR SPACE (U+200A), NARROW NO-BREAK SPACE (U+202F), MEDIUM MATHEMATICAL SPACE (U+205F), and IDEOGRAPHIC SPACE (U+3000).

  • UnicodeCategory.LineSeparator 类别的成员,仅包含行分隔符(U + 2028)。Members of the UnicodeCategory.LineSeparator category, which consists solely of the LINE SEPARATOR character (U+2028).

  • UnicodeCategory.ParagraphSeparator 类别的成员,仅由段落分隔符(U + 2029)组成。Members of the UnicodeCategory.ParagraphSeparator category, which consists solely of the PARAGRAPH SEPARATOR character (U+2029).

  • 字符表(U + 0009)、换行符(U + 000A)、行表(U + 000B)、换行(U + 000C)、回车符(u + 000D)和下一行(U + 0085)。The characters CHARACTER TABULATION (U+0009), LINE FEED (U+000A), LINE TABULATION (U+000B), FORM FEED (U+000C), CARRIAGE RETURN (U+000D), and NEXT LINE (U+0085).

IsWhiteSpace(Char)

指示指定的 Unicode 字符是否属于空格类别。Indicates whether the specified Unicode character is categorized as white space.

public:
 static bool IsWhiteSpace(char c);
public static bool IsWhiteSpace (char c);
static member IsWhiteSpace : char -> bool
Public Shared Function IsWhiteSpace (c As Char) As Boolean

Parameters

c
Char

要计算的 Unicode 字符。The Unicode character to evaluate.

Returns

Boolean

如果 true 是空格,则为 c;否则为 falsetrue if c is white space; otherwise, false.

Examples

下面的示例演示 IsWhiteSpace(Char) 方法。The following example demonstrates the IsWhiteSpace(Char) method.

using namespace System;
int main()
{
   String^ str =  "black matter";
   Console::WriteLine( Char::IsWhiteSpace( 'A' ) ); // Output: "False"
   Console::WriteLine( Char::IsWhiteSpace( str, 5 ) ); // Output: "True"
}

using System;

public class IsWhiteSpaceSample {
    public static void Main() {
        string str = "black matter";

        Console.WriteLine(Char.IsWhiteSpace('A'));		// Output: "False"
        Console.WriteLine(Char.IsWhiteSpace(str, 5));	// Output: "True"
    }
}
Module IsWhiteSpaceSample

    Sub Main()

        Dim str As String
        str = "black matter"

        Console.WriteLine(Char.IsWhiteSpace("A"c))      ' Output: "False"
        Console.WriteLine(Char.IsWhiteSpace(str, 5))    ' Output: "True"

    End Sub

End Module

Remarks

空白字符是以下 Unicode 字符:White space characters are the following Unicode characters:

  • UnicodeCategory.SpaceSeparator 类别的成员,包括字符空间(U + 0020)、无间断空格(U + 00A0)、欧甘空格标记(U + 1680)、EN 四(U + 2000)、EM 四(U + 2001)、半角空格(u + 2002)、EM 空间(U + 2003)、每半 em 空间(u + 2004)、四个每 EM 空格(u + 2005)、六个每全身空间(U + 2006)、图 SPACE (U + 2007)、标点空间(u + 2008)、细空间(U + 2009)、头发空间(U + 200A)、窄无间断空格(u + 202F)、中数学空间(u + 205F)和表意空间(U + 3000)。Members of the UnicodeCategory.SpaceSeparator category, which includes the characters SPACE (U+0020), NO-BREAK SPACE (U+00A0), OGHAM SPACE MARK (U+1680), EN QUAD (U+2000), EM QUAD (U+2001), EN SPACE (U+2002), EM SPACE (U+2003), THREE-PER-EM SPACE (U+2004), FOUR-PER-EM SPACE (U+2005), SIX-PER-EM SPACE (U+2006), FIGURE SPACE (U+2007), PUNCTUATION SPACE (U+2008), THIN SPACE (U+2009), HAIR SPACE (U+200A), NARROW NO-BREAK SPACE (U+202F), MEDIUM MATHEMATICAL SPACE (U+205F), and IDEOGRAPHIC SPACE (U+3000).

  • UnicodeCategory.LineSeparator 类别的成员,仅包含行分隔符(U + 2028)。Members of the UnicodeCategory.LineSeparator category, which consists solely of the LINE SEPARATOR character (U+2028).

  • UnicodeCategory.ParagraphSeparator 类别的成员,仅由段落分隔符(U + 2029)组成。Members of the UnicodeCategory.ParagraphSeparator category, which consists solely of the PARAGRAPH SEPARATOR character (U+2029).

  • 字符表(U + 0009)、换行符(U + 000A)、行表(U + 000B)、换行(U + 000C)、回车符(u + 000D)和下一行(U + 0085)。The characters CHARACTER TABULATION (U+0009), LINE FEED (U+000A), LINE TABULATION (U+000B), FORM FEED (U+000C), CARRIAGE RETURN (U+000D), and NEXT LINE (U+0085).

See also

IsWhiteSpace(String, Int32)

指示指定字符串中位于指定位置处的字符是否属于空格类别。Indicates whether the character at the specified position in a specified string is categorized as white space.

public:
 static bool IsWhiteSpace(System::String ^ s, int index);
public static bool IsWhiteSpace (string s, int index);
static member IsWhiteSpace : string * int -> bool
Public Shared Function IsWhiteSpace (s As String, index As Integer) As Boolean

Parameters

s
String

一个字符串。A string.

index
Int32

s 中要计算的字符的位置。The position of the character to evaluate in s.

Returns

Boolean

如果 true 中位于 index 的字符是空格,则为 s;否则为 falsetrue if the character at position index in s is white space; otherwise, false.

Exceptions

snulls is null.

index 小于零或大于 s 中最后一个位置。index is less than zero or greater than the last position in s.

Examples

下面的代码示例演示 IsWhiteSpaceThe following code example demonstrates IsWhiteSpace.

using namespace System;
int main()
{
   String^ str =  "black matter";
   Console::WriteLine( Char::IsWhiteSpace( 'A' ) ); // Output: "False"
   Console::WriteLine( Char::IsWhiteSpace( str, 5 ) ); // Output: "True"
}

using System;

public class IsWhiteSpaceSample {
    public static void Main() {
        string str = "black matter";

        Console.WriteLine(Char.IsWhiteSpace('A'));		// Output: "False"
        Console.WriteLine(Char.IsWhiteSpace(str, 5));	// Output: "True"
    }
}
Module IsWhiteSpaceSample

    Sub Main()

        Dim str As String
        str = "black matter"

        Console.WriteLine(Char.IsWhiteSpace("A"c))      ' Output: "False"
        Console.WriteLine(Char.IsWhiteSpace(str, 5))    ' Output: "True"

    End Sub

End Module

Remarks

字符串中的字符位置从零开始索引。Character positions in a string are indexed starting from zero.

空白字符是以下 Unicode 字符:White space characters are the following Unicode characters:

  • UnicodeCategory.SpaceSeparator 类别的成员,包括字符空间(U + 0020)、无间断空格(U + 00A0)、欧甘空格标记(U + 1680)、EN 四(U + 2000)、EM 四(U + 2001)、半角空格(u + 2002)、EM 空间(U + 2003)、每半 em 空间(u + 2004)、四个每 EM 空格(u + 2005)、六个每全身空间(U + 2006)、图 SPACE (U + 2007)、标点空间(u + 2008)、细空间(U + 2009)、头发空间(U + 200A)、窄无间断空格(u + 202F)、中数学空间(u + 205F)和表意空间(U + 3000)。Members of the UnicodeCategory.SpaceSeparator category, which includes the characters SPACE (U+0020), NO-BREAK SPACE (U+00A0), OGHAM SPACE MARK (U+1680), EN QUAD (U+2000), EM QUAD (U+2001), EN SPACE (U+2002), EM SPACE (U+2003), THREE-PER-EM SPACE (U+2004), FOUR-PER-EM SPACE (U+2005), SIX-PER-EM SPACE (U+2006), FIGURE SPACE (U+2007), PUNCTUATION SPACE (U+2008), THIN SPACE (U+2009), HAIR SPACE (U+200A), NARROW NO-BREAK SPACE (U+202F), MEDIUM MATHEMATICAL SPACE (U+205F), and IDEOGRAPHIC SPACE (U+3000).

  • UnicodeCategory.LineSeparator 类别的成员,仅包含行分隔符(U + 2028)。Members of the UnicodeCategory.LineSeparator category, which consists solely of the LINE SEPARATOR character (U+2028).

  • UnicodeCategory.ParagraphSeparator 类别的成员,仅由段落分隔符(U + 2029)组成。Members of the UnicodeCategory.ParagraphSeparator category, which consists solely of the PARAGRAPH SEPARATOR character (U+2029).

  • 字符表(U + 0009)、换行符(U + 000A)、行表(U + 000B)、换行(U + 000C)、回车符(u + 000D)和下一行(U + 0085)。The characters CHARACTER TABULATION (U+0009), LINE FEED (U+000A), LINE TABULATION (U+000B), FORM FEED (U+000C), CARRIAGE RETURN (U+000D), and NEXT LINE (U+0085).

See also

Applies to