Partager via


Char.IsWhiteSpace Method (String, Int32)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Indicates whether the character at the specified position in a specified string is categorized as white space.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Shared Function IsWhiteSpace ( _
    s As String, _
    index As Integer _
) As Boolean
public static bool IsWhiteSpace(
    string s,
    int index
)

Parameters

Return Value

Type: System.Boolean
true if the character at position index in s is white space; otherwise, false.

Exceptions

Exception Condition
ArgumentNullException

s is nulla null reference (Nothing in Visual Basic).

ArgumentOutOfRangeException

index is less than zero or greater than the last position in s.

Remarks

Character positions in a string are indexed starting from zero.

White space characters are the following Unicode characters:

  • Members of the SpaceSeparator category, which includes the characters SPACE (U+0020), OGHAM SPACE MARK (U+1680), MONGOLIAN VOWEL SEPARATOR (U+180E), 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).

  • Members of the LineSeparator category, which consists solely of the LINE SEPARATOR character (U+2028).

  • Members of the ParagraphSeparator category, which consists solely of the PARAGRAPH SEPARATOR character (U+2029).

  • The characters CHARACTER TABULATION (U+0009), LINE FEED (U+000A), LINE TABULATION (U+000B), FORM FEED (U+000C), CARRIAGE RETURN (U+000D), NEXT LINE (U+0085), and NO-BREAK SPACE (U+00A0).

Examples

The following example demonstrates IsWhiteSpace.


Module Example

   Public Sub Demo(ByVal outputBlock As System.Windows.Controls.TextBlock)

      Dim str As String
      str = "black matter"

      outputBlock.Text &= Char.IsWhiteSpace("A"c) & vbCrLf      ' Output: "False"
      outputBlock.Text += String.Format(Char.IsWhiteSpace(str, 5)) & vbCrLf    ' Output: "True"

   End Sub

End Module
using System;

public class Example
{
   public static void Demo(System.Windows.Controls.TextBlock outputBlock)
   {
      string str = "black matter";

      outputBlock.Text += Char.IsWhiteSpace('A') + "\n";                // Output: "False"
      outputBlock.Text += Char.IsWhiteSpace(str, 5) + "\n";             // Output: "True"
   }
}

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.