String.IndexOfAnyとは? わかりやすく解説

String.IndexOfAny メソッド (Char[])

Unicode 文字指定した配列内にある文字がこのインスタンス最初に見つかった位置インデックスレポートします

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Function IndexOfAny ( _
    anyOf As Char() _
) As Integer
Dim instance As String
Dim anyOf As Char()
Dim returnValue As Integer

returnValue = instance.IndexOfAny(anyOf)
public int IndexOfAny (
    char[] anyOf
)
public:
int IndexOfAny (
    array<wchar_t>^ anyOf
)
public int IndexOfAny (
    char[] anyOf
)
public function IndexOfAny (
    anyOf : char[]
) : int

パラメータ

anyOf

シークする 1 つ上の文字格納している、Unicode 文字配列

戻り値
anyOf 内の文字がこのインスタンス最初に見つかった場所のインデックス位置anyOf 内の文字見つからなかった場合は -1。

例外例外
例外種類条件

ArgumentNullException

anyOfnull 参照 (Visual Basic では Nothing) です。

解説解説

インデックス番号付けは 0 から始まります

anyOf検索では大文字と小文字区別されます。

このメソッドは、序数 (カルチャに依存しない) 検索実行します。この検索方法では、2 つ文字Unicode スカラ値が等しいときだけ等価と見なされます。カルチャに依存した検索実行するには、CompareInfo.IndexOf メソッド使用します。このメソッド使用して検索すると、合字の "A" (U+00C6) のような構成済み文字を表す Unicode 値は、'AE' (U+0041, U+0045) のようにその文字構成要素正し順序出現した場合、これらの構成要素と (カルチャの種類に応じて) 等価と見なされます

使用例使用例

IndexOfAny メソッド使用してユーザー入力した文字列内の無効な文字チェックする方法については、次のコード例参照してください

' Get the tree node under the mouse pointer and
' save it in the mySelectedNode variable. 
Private Sub treeView1_MouseDown(sender As
 Object, _
  e As System.Windows.Forms.MouseEventArgs)
        
   mySelectedNode = treeView1.GetNodeAt(e.X, e.Y)
End Sub    
    
Private Sub menuItem1_Click(sender As
 Object, e As System.EventArgs)
   If Not (mySelectedNode Is
 Nothing) And _
     Not (mySelectedNode.Parent Is Nothing)
 Then
      treeView1.SelectedNode = mySelectedNode
      treeView1.LabelEdit = True
      If Not mySelectedNode.IsEditing Then
         mySelectedNode.BeginEdit()
      End If
   Else
      MessageBox.Show("No tree node selected or selected node
 is a root node." & _
        Microsoft.VisualBasic.ControlChars.Cr & _
        "Editing of root nodes is not allowed.", "Invalid
 selection")
   End If
End Sub    
    
Private Sub treeView1_AfterLabelEdit(sender
 As Object, _
  e As System.Windows.Forms.NodeLabelEditEventArgs)
   If Not (e.Label Is Nothing)
 Then
      If e.Label.Length > 0 Then
         If e.Label.IndexOfAny(New Char()
 {"@"c, "."c, ","c,
 "!"c}) = -1 Then
            ' Stop editing without canceling the label change.
            e.Node.EndEdit(False)
         Else
            ' Cancel the label edit action, inform the user, and
            ' place the node in edit mode again. 
            e.CancelEdit = True
            MessageBox.Show("Invalid tree node label."
 & _
              Microsoft.VisualBasic.ControlChars.Cr & _
              "The invalid characters are: '@','.', ',', '!'",
 _
              "Node Label Edit")
            e.Node.BeginEdit()
         End If
      Else
         ' Cancel the label edit action, inform the user, and
         ' place the node in edit mode again. 
         e.CancelEdit = True
         MessageBox.Show("Invalid tree node label."
 & _
           Microsoft.VisualBasic.ControlChars.Cr & _
           "The label cannot be blank", "Node
 Label Edit")
           e.Node.BeginEdit()
      End If
         Me.treeView1.LabelEdit = False
   End If
End Sub 
/* Get the tree node under the mouse pointer and 
   save it in the mySelectedNode variable. */
private void treeView1_MouseDown(object sender,
 
  System.Windows.Forms.MouseEventArgs e)
{
   mySelectedNode = treeView1.GetNodeAt(e.X, e.Y);
}

private void menuItem1_Click(object sender,
 System.EventArgs e)
{
   if (mySelectedNode != null && mySelectedNode.Parent
 != null)
   {
      treeView1.SelectedNode = mySelectedNode;
      treeView1.LabelEdit = true;
      if(!mySelectedNode.IsEditing)
      {
         mySelectedNode.BeginEdit();
      }
   }
   else
   {
      MessageBox.Show("No tree node selected or selected node is a root node.\n"
 + 
         "Editing of root nodes is not allowed.", "Invalid selection");
   }
}

private void treeView1_AfterLabelEdit(object
 sender, 
         System.Windows.Forms.NodeLabelEditEventArgs e)
{
   if (e.Label != null)
   {
     if(e.Label.Length > 0)
     {
        if (e.Label.IndexOfAny(new char[]{'@',
 '.', ',', '!'}) == -1)
        {
           // Stop editing without canceling the label change.
           e.Node.EndEdit(false);
        }
        else
        {
           /* Cancel the label edit action, inform the user, and 
              place the node in edit mode again. */
           e.CancelEdit = true;
           MessageBox.Show("Invalid tree node label.\n" + 
              "The invalid characters are: '@','.', ',', '!'", 
              "Node Label Edit");
           e.Node.BeginEdit();
        }
     }
     else
     {
        /* Cancel the label edit action, inform the user, and 
           place the node in edit mode again. */
        e.CancelEdit = true;
        MessageBox.Show("Invalid tree node label.\nThe label cannot be blank",
 
           "Node Label Edit");
        e.Node.BeginEdit();
     }
     this.treeView1.LabelEdit = false;
   }
}
   /* Get the tree node under the mouse pointer and 
      save it in the mySelectedNode variable. */
private:
   void treeView1_MouseDown( Object^ /*sender*/, System::Windows::Forms::MouseEventArgs^
 e )
   {
      mySelectedNode = treeView1->GetNodeAt( e->X, e->Y );
   }

   void menuItem1_Click( Object^ /*sender*/, System::EventArgs^
 /*e*/ )
   {
      if ( mySelectedNode != nullptr && mySelectedNode->Parent
 != nullptr )
      {
         treeView1->SelectedNode = mySelectedNode;
         treeView1->LabelEdit = true;
         if (  !mySelectedNode->IsEditing )
         {
            mySelectedNode->BeginEdit();
         }
      }
      else
      {
         MessageBox::Show( String::Concat( "No tree node selected or selected
 node is a root node.\n",
            "Editing of root nodes is not allowed." ), "Invalid selection"
 );
      }
   }

   void treeView1_AfterLabelEdit( Object^ /*sender*/,
      System::Windows::Forms::NodeLabelEditEventArgs^ e )
   {
      if ( e->Label != nullptr )
      {
         if ( e->Label->Length > 0 )
         {
            array<Char>^ temp0 = {'@','.',',','!'};
            if ( e->Label->IndexOfAny( temp0 ) == -1 )
            {
               
               // Stop editing without canceling the label change.
               e->Node->EndEdit( false );
            }
            else
            {
               /* Cancel the label edit action, inform the user, and 
                  place the node in edit mode again. */
               e->CancelEdit = true;
               MessageBox::Show( String::Concat( "Invalid tree node label.\n"
,
                  "The invalid characters are: '@','.', ',', '!'" ),
                  "Node Label Edit" );
               e->Node->BeginEdit();
            }
         }
         else
         {
            /* Cancel the label edit action, inform the user, and 
               place the node in edit mode again. */
            e->CancelEdit = true;
            MessageBox::Show( "Invalid tree node label.\nThe label cannot be
 blank",
               "Node Label Edit" );
            e->Node->BeginEdit();
         }
         this->treeView1->LabelEdit = false;
      }
   }
/* Get the tree node under the mouse pointer and 
   save it in the mySelectedNode variable. 
 */
private void treeView1_MouseDown(Object sender,
 
                                 System.Windows.Forms.MouseEventArgs e)
{
    mySelectedNode = treeView1.GetNodeAt(e.get_X(), e.get_Y());
} //treeView1_MouseDown

private void menuItem1_Click(Object sender,
 System.EventArgs e)
{
    if (mySelectedNode != null && mySelectedNode.get_Parent()
 != null) {
        treeView1.set_SelectedNode(mySelectedNode);
        treeView1.set_LabelEdit(true);
        if (!(mySelectedNode.get_IsEditing())) {
            mySelectedNode.BeginEdit();
        }
    }
    else {
        MessageBox.Show("No tree node selected or selected node"
            + "is a root node.\n" 
            + "Editing of root nodes is not allowed.", "Invalid selection");
    }
} //menuItem1_Click

private void treeView1_AfterLabelEdit(Object
 sender, 
                            System.Windows.Forms.NodeLabelEditEventArgs e)
{
    if (e.get_Label()!= null) {
        if (e.get_Label().length() > 0) {
            if (e.get_Label().IndexOfAny((new
 char[]{ '@', '.', ',', '!' }))
                == -1) {
                // Stop editing without canceling the label change.
                e.get_Node().EndEdit(false);
            }
            else {
                /* Cancel the label edit action, inform the user, and 
                   place the node in edit mode again. 
                 */
                e.set_CancelEdit(true);
                MessageBox.Show("Invalid tree node label.\n" 
                    + "The invalid characters are: "
                    + "'@','.', ',', '!'", "Node Label Edit");
                e.get_Node().BeginEdit();
            }
        }
        else {
            /* Cancel the label edit action, inform the user, and 
               place the node in edit mode again.
             */
            e.set_CancelEdit(true);
            MessageBox.Show("Invalid tree node label.\n"
                + "The label cannot be blank", "Node Label Edit");
            e.get_Node().BeginEdit();
        }
        this.treeView1.set_LabelEdit(false);
    }
} //treeView1_AfterLabelEdit
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

String.IndexOfAny メソッド (Char[], Int32)

Unicode 文字指定した配列内にある文字がこのインスタンス最初に見つかった位置インデックスレポートします検索は、指定した文字位置から開始されます。

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Function IndexOfAny ( _
    anyOf As Char(), _
    startIndex As Integer _
) As Integer
Dim instance As String
Dim anyOf As Char()
Dim startIndex As Integer
Dim returnValue As Integer

returnValue = instance.IndexOfAny(anyOf, startIndex)
public int IndexOfAny (
    char[] anyOf,
    int startIndex
)
public:
int IndexOfAny (
    array<wchar_t>^ anyOf, 
    int startIndex
)
public int IndexOfAny (
    char[] anyOf, 
    int startIndex
)
public function IndexOfAny (
    anyOf : char[], 
    startIndex : int
) : int

パラメータ

anyOf

シークする 1 つ上の文字格納している、Unicode 文字配列

startIndex

検索開始される位置

戻り値
anyOf 内の文字がこのインスタンス最初に見つかった場所のインデックス位置anyOf 内の文字見つからなかった場合は -1。

例外例外
例外種類条件

ArgumentNullException

anyOfnull 参照 (Visual Basic では Nothing) です。

ArgumentOutOfRangeException

startIndex が負の値です。

または

startIndex が、このインスタンス文字数超えてます。

解説解説

インデックス番号付けは 0 から始まります

検索範囲startIndex から文字列末尾までです。

anyOf検索では大文字と小文字区別されます。

このメソッドは、序数 (カルチャに依存しない) 検索実行します。この検索方法では、2 つ文字Unicode スカラ値が等しいときだけ等価と見なされます。カルチャに依存した検索実行するには、CompareInfo.IndexOf メソッド使用します。このメソッド使用して検索すると、合字の "A" (U+00C6) のような構成済み文字を表す Unicode 値は、'AE' (U+0041, U+0045) のようにその文字構成要素正し順序出現した場合、これらの構成要素と (カルチャの種類に応じて) 等価と見なされます

使用例使用例

部分文字列から、"is" を構成する任意の文字出現するインデックス位置検索するコード例次に示します

' Sample for String.IndexOfAny(Char[], Int32)
Imports System

Class Sample
   Public Shared Sub Main()
      Dim br1 As String
 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"
      Dim br2 As String
 = "0123456789012345678901234567890123456789012345678901234567890123456"
      Dim str As String
 = "Now is the time for all good men to come to the aid of their
 party."
      Dim start As Integer
      Dim at As Integer
      Dim target As String
 = "is"
      Dim anyOf As Char()
 = target.ToCharArray()
      
      start = str.Length / 2
      Console.WriteLine()
      Console.WriteLine("Search for a character occurrence from
 position {0} to {1}.", _
                           start, str.Length - 1)
      Console.WriteLine("{1}{0}{2}{0}{3}{0}", Environment.NewLine,
 br1, br2, str)
      Console.Write("A character in '{0}' occurs
 at position: ", target)
      at = str.IndexOfAny(anyOf, start)
      If at > - 1 Then
         Console.Write(at)
      Else
         Console.Write("(not found)")
      End If
      Console.WriteLine()
   End Sub 'Main
End Class 'Sample
'
'
'Search for a character occurrence from position 33 to 66.
'0----+----1----+----2----+----3----+----4----+----5----+----6----+-
'0123456789012345678901234567890123456789012345678901234567890123456
'Now is the time for all good men to come to the aid of their party.
'
'A character in 'is' occurs at position: 49
'
// Sample for String.IndexOfAny(Char[], Int32)
using System;

class Sample {
    public static void Main()
 
    {
    string br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-";
    string br2 = "0123456789012345678901234567890123456789012345678901234567890123456";
    string str = "Now is the time for
 all good men to come to the aid of their party.";
    int start;
    int at;
    string target = "is";
    char[] anyOf = target.ToCharArray();

    start = str.Length/2;
    Console.WriteLine();
    Console.WriteLine("The first character occurrence from position {0} to {1}.",
 
                           start, str.Length-1);
    Console.WriteLine("{1}{0}{2}{0}{3}{0}", Environment.NewLine, br1, br2,
 str);
    Console.Write("A character in '{0}' occurs at position:
 ", target);

    at = str.IndexOfAny(anyOf, start);
    if (at > -1) 
        Console.Write(at);
    else
        Console.Write("(not found)");
    Console.WriteLine();
    }
}
/*

The first character occurrence from position 33 to 66.
0----+----1----+----2----+----3----+----4----+----5----+----6----+-
0123456789012345678901234567890123456789012345678901234567890123456
Now is the time for all good men to come to the aid of their party.

A character in 'is' occurs at position: 49

*/
// Sample for String::IndexOfAny(Char[], Int32)
using namespace System;
int main()
{
   String^ br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-";
   String^ br2 = "0123456789012345678901234567890123456789012345678901234567890123456";
   String^ str = "Now is the time for all good men to come
 to the aid of their party.";
   int start;
   int at;
   String^ target = "is";
   array<Char>^anyOf = target->ToCharArray();
   start = str->Length / 2;
   Console::WriteLine();
   Console::WriteLine( "The first character occurrence from position {0} to
 {1}.", start, str->Length - 1 );
   Console::WriteLine( "{1}{0}{2}{0}{3}{0}", Environment::NewLine, br1,
 br2, str );
   Console::Write( "A character in '{0}' occurs at position:
 ", target );
   at = str->IndexOfAny( anyOf, start );
   if ( at > -1 )
      Console::Write( at );
   else
      Console::Write( "(not found)" );

   Console::WriteLine();
}

/*

The first character occurrence from position 33 to 66.
0----+----1----+----2----+----3----+----4----+----5----+----6----+-
0123456789012345678901234567890123456789012345678901234567890123456
Now is the time for all good men to come to the aid of their party.

A character in 'is' occurs at position: 49

*/
// Sample for String.IndexOfAny(Char[], Int32)
import System.*;

class Sample
{
    public static void main(String[]
 args)
    {
        String br1 = "0----+----1----+----2----+----3----+----4----+----5----"
            + "+----6----+-";
        String br2 = "012345678901234567890123456789012345678901234567890123"
            + "4567890123456";
        String str = "Now is the time for all good men to
 come to the aid of "
            + "their party.";
        int start;
        int at;
        String target = "is";
        char anyOf[] = target.ToCharArray();

        start = str.get_Length() / 2;
        Console.WriteLine();
        Console.WriteLine("The first character occurrence from position {0}
 to "
            + "{1}.", (Int32)start, (Int32)(str.get_Length() - 1));
        Console.Write("{1}{0}", Environment.get_NewLine(), br1);
        Console.Write("{1}{0}", Environment.get_NewLine(), br2);
        Console.WriteLine("{1}{0}", Environment.get_NewLine(), str);
        Console.Write("A character in '{0}' occurs at position:
 ", target);

        at = str.IndexOfAny(anyOf, start);
        if (at > -1) {
            Console.Write(at);
        }
        else {
            Console.Write("(not found)");
        }
        Console.WriteLine();
    } //main
} //Sample
/*

The first character occurrence from position 33 to 66.
0----+----1----+----2----+----3----+----4----+----5----+----6----+-
0123456789012345678901234567890123456789012345678901234567890123456
Now is the time for all good men to come to the aid of their party.

A character in 'is' occurs at position: 49

*/
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

String.IndexOfAny メソッド (Char[], Int32, Int32)

Unicode 文字指定した配列内にある文字がこのインスタンス最初に見つかった位置インデックスレポートします検索指定した文字位置から開始され指定した数の文字位置検査されます。

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Function IndexOfAny ( _
    anyOf As Char(), _
    startIndex As Integer, _
    count As Integer _
) As Integer
Dim instance As String
Dim anyOf As Char()
Dim startIndex As Integer
Dim count As Integer
Dim returnValue As Integer

returnValue = instance.IndexOfAny(anyOf, startIndex, count)
public int IndexOfAny (
    char[] anyOf,
    int startIndex,
    int count
)
public:
int IndexOfAny (
    array<wchar_t>^ anyOf, 
    int startIndex, 
    int count
)
public int IndexOfAny (
    char[] anyOf, 
    int startIndex, 
    int count
)
public function IndexOfAny (
    anyOf : char[], 
    startIndex : int, 
    count : int
) : int

パラメータ

anyOf

シークする 1 つ上の文字格納している、Unicode 文字配列

startIndex

検索開始される位置

count

検査する文字位置の数。

戻り値
anyOf 内の文字がこのインスタンス最初に見つかった場所のインデックス位置anyOf 内の文字見つからなかった場合は -1。

例外例外
例外種類条件

ArgumentNullException

anyOfnull 参照 (Visual Basic では Nothing) です。

ArgumentOutOfRangeException

count または startIndex が負の値です。

または

count + startIndex が、このインスタンス文字数超えてます。

解説解説

startIndex から startIndex + count -1 番目の位置で検索実行されましたが、startIndex + count文字検出されませんでした

インデックス番号付けは 0 から始まります

anyOf検索では大文字と小文字区別されます。

このメソッドは、序数 (カルチャに依存しない) 検索実行します。この検索方法では、2 つ文字Unicode スカラ値が等しいときだけ等価と見なされます。カルチャに依存した検索実行するには、CompareInfo.IndexOf メソッド使用します。このメソッド使用して検索すると、合字の "A" (U+00C6) のような構成済み文字を表す Unicode 値は、'AE' (U+0041, U+0045) のようにその文字構成要素正し順序出現した場合、これらの構成要素と (カルチャの種類に応じて) 等価と見なされます

使用例使用例

部分文字列から、"aid" を構成する任意の文字出現するインデックス位置検索するコード例次に示します

' Sample for String.IndexOfAny(Char[], Int32, Int32)
Imports System

Class Sample
   Public Shared Sub Main()
      Dim br1 As String
 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-"
      Dim br2 As String
 = "0123456789012345678901234567890123456789012345678901234567890123456"
      Dim str As String
 = "Now is the time for all good men to come to the aid of their
 party."
      Dim start As Integer
      Dim at As Integer
      Dim count As Integer
      Dim target As String
 = "aid"
      Dim anyOf As Char()
 = target.ToCharArray()
      
      start =(str.Length - 1) / 3
      count =(str.Length - 1) / 4
      Console.WriteLine()
      Console.WriteLine("The first character occurrence from position
 {0} for {1} characters.", start, count)
      Console.WriteLine("{1}{0}{2}{0}{3}{0}", Environment.NewLine,
 br1, br2, str)
      Console.Write("A character in '{0}' occurs
 at position: ", target)
      
      at = str.IndexOfAny(anyOf, start, count)
      If at > - 1 Then
         Console.Write(at)
      Else
         Console.Write("(not found)")
      End If
      Console.WriteLine()
   End Sub 'Main
End Class 'Sample
'
'The first character occurrence from position 22 for 16 characters.
'0----+----1----+----2----+----3----+----4----+----5----+----6----+-
'0123456789012345678901234567890123456789012345678901234567890123456
'Now is the time for all good men to come to the aid of their party.
'
'A character in 'aid' occurs at position: 27
'
// Sample for String.IndexOfAny(Char[], Int32, Int32)
using System;

class Sample {
    public static void Main()
 
    {
    string br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-";
    string br2 = "0123456789012345678901234567890123456789012345678901234567890123456";
    string str = "Now is the time for
 all good men to come to the aid of their party.";
    int start;
    int at;
    int count;
    string target = "aid";
    char[] anyOf = target.ToCharArray();

    start = (str.Length-1)/3;
    count = (str.Length-1)/4;
    Console.WriteLine();
    Console.WriteLine("The first character occurrence from position {0} for
 {1} characters.", start, count);
    Console.WriteLine("{1}{0}{2}{0}{3}{0}", Environment.NewLine, br1, br2,
 str);
    Console.Write("A character in '{0}' occurs at position:
 ", target);

    at = str.IndexOfAny(anyOf, start, count);
    if (at > -1) 
        Console.Write(at);
    else
        Console.Write("(not found)");
    Console.WriteLine();
    }
}
/*

The first character occurrence from position 22 for 16 characters.
0----+----1----+----2----+----3----+----4----+----5----+----6----+-
0123456789012345678901234567890123456789012345678901234567890123456
Now is the time for all good men to come to the aid of their party.

A character in 'aid' occurs at position: 27

*/
// Sample for String::IndexOfAny(Char[], Int32, Int32)
using namespace System;
int main()
{
   String^ br1 = "0----+----1----+----2----+----3----+----4----+----5----+----6----+-";
   String^ br2 = "0123456789012345678901234567890123456789012345678901234567890123456";
   String^ str = "Now is the time for all good men to come
 to the aid of their party.";
   int start;
   int at;
   int count;
   String^ target = "aid";
   array<Char>^anyOf = target->ToCharArray();
   start = (str->Length - 1) / 3;
   count = (str->Length - 1) / 4;
   Console::WriteLine();
   Console::WriteLine( "The first character occurrence from position {0} for
 {1} characters.", start, count );
   Console::WriteLine( "{1}{0}{2}{0}{3}{0}", Environment::NewLine, br1,
 br2, str );
   Console::Write( "A character in '{0}' occurs at position:
 ", target );
   at = str->IndexOfAny( anyOf, start, count );
   if ( at > -1 )
      Console::Write( at );
   else
      Console::Write( "(not found)" );

   Console::WriteLine();
}

/*

The first character occurrence from position 22 for 16 characters.
0----+----1----+----2----+----3----+----4----+----5----+----6----+-
0123456789012345678901234567890123456789012345678901234567890123456
Now is the time for all good men to come to the aid of their party.

A character in 'aid' occurs at position: 27

*/
// Sample for String.IndexOfAny(Char[], Int32, Int32)
import System.*;

class Sample
{
    public static void main(String[]
 args)
    {
        String br1 = "0----+----1----+----2----+----3----+----4----+----5----+"
            + "----6----+-";
        String br2 = "01234567890123456789012345678901234567890123456789012345"
            + "67890123456";
        String str = "Now is the time for all good men to
 come to the aid of "
            + "their party.";
        int start;
        int at;
        int count;
        String target = "aid";
        char anyOf[] = target.ToCharArray();

        start = (str.get_Length() - 1) / 3;
        count = (str.get_Length() - 1) / 4;
        Console.WriteLine();
        Console.WriteLine("The first character occurrence from position {0}
 "
            + "for {1} characters.", (Int32)start, (Int32)count);
        Console.Write("{1}{0}", Environment.get_NewLine(), br1);
        Console.Write("{1}{0}", Environment.get_NewLine(), br2);
        Console.WriteLine("{1}{0}", Environment.get_NewLine(), str);
        Console.Write("A character in '{0}' occurs at position:
 ", target);

        at = str.IndexOfAny(anyOf, start, count);
        if (at > -1) {
            Console.Write(at);
        }
        else {
            Console.Write("(not found)");
        }
        Console.WriteLine();
    } //main
} //Sample
/*

The first character occurrence from position 22 for 16 characters.
0----+----1----+----2----+----3----+----4----+----5----+----6----+-
0123456789012345678901234567890123456789012345678901234567890123456
Now is the time for all good men to come to the aid of their party.

A character in 'aid' occurs at position: 27

*/
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

String.IndexOfAny メソッド



このページでは「.NET Framework クラス ライブラリ リファレンス」からString.IndexOfAnyを検索した結果を表示しています。
Weblioに収録されているすべての辞書からString.IndexOfAnyを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からString.IndexOfAny を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「String.IndexOfAny」の関連用語

String.IndexOfAnyのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



String.IndexOfAnyのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS