Char.IsSeparator Char.IsSeparator Char.IsSeparator Char.IsSeparator Method

定義

指示 Unicode 字元是否分類為分隔符號字元。Indicates whether a Unicode character is categorized as a separator character.

多載

IsSeparator(Char) IsSeparator(Char) IsSeparator(Char) IsSeparator(Char)

指示指定的 Unicode 字元是否分類為分隔符號字元。Indicates whether the specified Unicode character is categorized as a separator character.

IsSeparator(String, Int32) IsSeparator(String, Int32) IsSeparator(String, Int32) IsSeparator(String, Int32)

指示指定的字串中指定位置處的字元是否分類為分隔符號字元。Indicates whether the character at the specified position in a specified string is categorized as a separator character.

備註

Unicode standard 可識別三個子類別的分隔符號:The Unicode standard recognizes three subcategories of separators:

注意

Unicode 標準會將字元 \u000A (LF)、\u000C (FF)和 \u000D (CR)分類為控制字元( UnicodeCategory.Control分類的成員),而不是分隔字元。The Unicode standard classifies the characters \u000A (LF), \u000C (FF), and \u000D (CR) as control characters (members of the UnicodeCategory.Control category), not as separator characters.

IsSeparator(Char) IsSeparator(Char) IsSeparator(Char) IsSeparator(Char)

指示指定的 Unicode 字元是否分類為分隔符號字元。Indicates whether the specified Unicode character is categorized as a separator character.

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

參數

c
Char Char Char Char

要評估的 Unicode 字元。The Unicode character to evaluate.

傳回

true 是分隔符號字元時為 c,否則為 falsetrue if c is a separator character; otherwise, false.

範例

下列範例會列出分類Char為分隔字元的物件。The following example lists the Char objects that are classified as separator characters.

using namespace System;

int main()
{
   for (int ctr = Convert::ToInt32(Char::MinValue); ctr <= Convert::ToInt32(Char::MaxValue); ctr++)
   {
      wchar_t ch = ctr;
      if (Char::IsSeparator(ch))
         Console::WriteLine("\u{0:X4} ({1})", (int) ch, Char::GetUnicodeCategory(ch).ToString());
   }
}
// The example displays the following output:
//       0020 (SpaceSeparator)
//       u00A0 (SpaceSeparator)
//       u1680 (SpaceSeparator)
//       u180E (SpaceSeparator)
//       u2000 (SpaceSeparator)
//       u2001 (SpaceSeparator)
//       u2002 (SpaceSeparator)
//       u2003 (SpaceSeparator)
//       u2004 (SpaceSeparator)
//       u2005 (SpaceSeparator)
//       u2006 (SpaceSeparator)
//       u2007 (SpaceSeparator)
//       u2008 (SpaceSeparator)
//       u2009 (SpaceSeparator)
//       u200A (SpaceSeparator)
//       u2028 (LineSeparator)
//       u2029 (ParagraphSeparator)
//       u202F (SpaceSeparator)
//       u205F (SpaceSeparator)
//       u3000 (SpaceSeparator)
using System;

public class Class1
{
   public static void Main()
   {
      for (int ctr = Convert.ToInt32(Char.MinValue); ctr <= Convert.ToInt32(Char.MaxValue); ctr++)
      {
         char ch = (Char) ctr;
         if (Char.IsSeparator(ch))
            Console.WriteLine(@"\u{0:X4} ({1})", (int) ch, Char.GetUnicodeCategory(ch).ToString());
      }
   }
}
// The example displays the following output:
//       \u0020 (SpaceSeparator)
//       \u00A0 (SpaceSeparator)
//       \u1680 (SpaceSeparator)
//       \u180E (SpaceSeparator)
//       \u2000 (SpaceSeparator)
//       \u2001 (SpaceSeparator)
//       \u2002 (SpaceSeparator)
//       \u2003 (SpaceSeparator)
//       \u2004 (SpaceSeparator)
//       \u2005 (SpaceSeparator)
//       \u2006 (SpaceSeparator)
//       \u2007 (SpaceSeparator)
//       \u2008 (SpaceSeparator)
//       \u2009 (SpaceSeparator)
//       \u200A (SpaceSeparator)
//       \u2028 (LineSeparator)
//       \u2029 (ParagraphSeparator)
//       \u202F (SpaceSeparator)
//       \u205F (SpaceSeparator)
//       \u3000 (SpaceSeparator)
Module Example
   Public Sub Main()
      For ctr As Integer = Convert.ToInt32(Char.MinValue) To Convert.ToInt32(Char.MaxValue)
         Dim ch As Char = ChrW(ctr)
         If Char.IsSeparator(ch) Then
            Console.WriteLine("\u{0:X4} ({1})", AscW(ch), Char.GetUnicodeCategory(ch).ToString())
         End If
      Next
   End Sub
End Module
' The example displays the following output:
'       \u0020 (SpaceSeparator)
'       \u00A0 (SpaceSeparator)
'       \u1680 (SpaceSeparator)
'       \u180E (SpaceSeparator)
'       \u2000 (SpaceSeparator)
'       \u2001 (SpaceSeparator)
'       \u2002 (SpaceSeparator)
'       \u2003 (SpaceSeparator)
'       \u2004 (SpaceSeparator)
'       \u2005 (SpaceSeparator)
'       \u2006 (SpaceSeparator)
'       \u2007 (SpaceSeparator)
'       \u2008 (SpaceSeparator)
'       \u2009 (SpaceSeparator)
'       \u200A (SpaceSeparator)
'       \u2028 (LineSeparator)
'       \u2029 (ParagraphSeparator)
'       \u202F (SpaceSeparator)
'       \u205F (SpaceSeparator)
'       \u3000 (SpaceSeparator)

備註

Unicode standard 可識別三個子類別的分隔符號:The Unicode standard recognizes three subcategories of separators:

注意

Unicode 標準會將字元 \u000A (LF)、\u000C (FF)和 \u000D (CR)分類為控制字元( UnicodeCategory.Control分類的成員),而不是分隔字元。The Unicode standard classifies the characters \u000A (LF), \u000C (FF), and \u000D (CR) as control characters (members of the UnicodeCategory.Control category), not as separator characters.

另請參閱

IsSeparator(String, Int32) IsSeparator(String, Int32) IsSeparator(String, Int32) IsSeparator(String, Int32)

指示指定的字串中指定位置處的字元是否分類為分隔符號字元。Indicates whether the character at the specified position in a specified string is categorized as a separator character.

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

參數

s
String String String String

字串。A string.

index
Int32 Int32 Int32 Int32

要評估的字元在 s 中的位置。The position of the character to evaluate in s.

傳回

true 中位於index 的字元是分隔符號字元時為 s,否則為 falsetrue if the character at position index in s is a separator character; otherwise, false.

例外狀況

index 小於零或大於 s 中的最後一個位置。index is less than zero or greater than the last position in s.

範例

下列範例會示範IsSeparatorThe following example demonstrates IsSeparator.

using namespace System;
int main()
{
   String^ str =  "twain1 twain2";
   Console::WriteLine( Char::IsSeparator( 'a' ) ); // Output: "False"
   Console::WriteLine( Char::IsSeparator( str, 6 ) ); // Output: "True"
}

using System;

public class IsSeparatorSample {
    public static void Main() {
        string str = "twain1 twain2";

        Console.WriteLine(Char.IsSeparator('a'));		// Output: "False"
        Console.WriteLine(Char.IsSeparator(str, 6));	// Output: "True"
    }
}
Module IsSeparatorSample

    Sub Main()

        Dim str As String
        str = "twain1 twain2"

        Console.WriteLine(Char.IsSeparator("a"c))       ' Output: "False"
        Console.WriteLine(Char.IsSeparator(str, 6))     ' Output: "True"

    End Sub

End Module

備註

字串中的字元位置會從零開始編制索引。Character positions in a string are indexed starting from zero.

Unicode standard 可識別三個子類別的分隔符號:The Unicode standard recognizes three subcategories of separators:

注意

Unicode 標準會將字元 \u000A (LF)、\u000C (FF)和 \u000D (CR)分類為控制字元( UnicodeCategory.Control分類的成員),而不是分隔字元。The Unicode standard classifies the characters \u000A (LF), \u000C (FF), and \u000D (CR) as control characters (members of the UnicodeCategory.Control category), not as separator characters.

另請參閱

適用於