String.LastIndexOfAny String.LastIndexOfAny String.LastIndexOfAny String.LastIndexOfAny Method

Definition

유니코드 배열에서 지정된 하나 이상의 문자 중에 이 인스턴스에서 마지막으로 발견되는 문자의 0부터 시작하는 인덱스 위치를 보고합니다. Reports the zero-based index position of the last occurrence in this instance of one or more characters specified in a Unicode array. 이 인스턴스에 해당 문자가 없으면 메서드는 -1을 반환합니다. The method returns -1 if the characters in the array are not found in this instance.

Overloads

LastIndexOfAny(Char[]) LastIndexOfAny(Char[]) LastIndexOfAny(Char[]) LastIndexOfAny(Char[])

유니코드 배열에서 지정된 하나 이상의 문자 중에 이 인스턴스에서 마지막으로 발견되는 문자의 0부터 시작하는 인덱스 위치를 보고합니다. Reports the zero-based index position of the last occurrence in this instance of one or more characters specified in a Unicode array.

LastIndexOfAny(Char[], Int32) LastIndexOfAny(Char[], Int32) LastIndexOfAny(Char[], Int32) LastIndexOfAny(Char[], Int32)

유니코드 배열에서 지정된 하나 이상의 문자 중에 이 인스턴스에서 마지막으로 발견되는 문자의 0부터 시작하는 인덱스 위치를 보고합니다. Reports the zero-based index position of the last occurrence in this instance of one or more characters specified in a Unicode array. 지정된 문자 위치에서 시작하고 문자열의 시작 부분을 향해 뒤로 검색이 진행됩니다. The search starts at a specified character position and proceeds backward toward the beginning of the string.

LastIndexOfAny(Char[], Int32, Int32) LastIndexOfAny(Char[], Int32, Int32) LastIndexOfAny(Char[], Int32, Int32) LastIndexOfAny(Char[], Int32, Int32)

유니코드 배열에서 지정된 하나 이상의 문자 중에 이 인스턴스에서 마지막으로 발견되는 문자의 0부터 시작하는 인덱스 위치를 보고합니다. Reports the zero-based index position of the last occurrence in this instance of one or more characters specified in a Unicode array. 지정된 문자 위치에서 검색을 시작하여 지정된 수의 문자 위치에 대한 문자열의 시작 부분 쪽으로 뒤로 검색합니다. The search starts at a specified character position and proceeds backward toward the beginning of the string for a specified number of character positions.

LastIndexOfAny(Char[]) LastIndexOfAny(Char[]) LastIndexOfAny(Char[]) LastIndexOfAny(Char[])

유니코드 배열에서 지정된 하나 이상의 문자 중에 이 인스턴스에서 마지막으로 발견되는 문자의 0부터 시작하는 인덱스 위치를 보고합니다. Reports the zero-based index position of the last occurrence in this instance of one or more characters specified in a Unicode array.

public:
 int LastIndexOfAny(cli::array <char> ^ anyOf);
public int LastIndexOfAny (char[] anyOf);
member this.LastIndexOfAny : char[] -> int
Public Function LastIndexOfAny (anyOf As Char()) As Integer

매개 변수

anyOf
Char[]

검색할 문자를 하나 이상 포함하는 유니코드 문자 배열입니다. A Unicode character array containing one or more characters to seek.

Returns

이 인스턴스에서 anyOf의 문자가 마지막으로 발견된 인덱스 위치입니다. anyOf의 문자가 발견되지 않으면 -1입니다. The index position of the last occurrence in this instance where any character in anyOf was found; -1 if no character in anyOf was found.

Exceptions

Examples

다음 예제에서는 다른 문자열 내에서 "is" 문자열에 있는 문자 중 마지막 요소의 인덱스를 찾습니다.The following example finds the index of the last occurrence of any character in the string "is" within another string.

// Sample for String::LastIndexOfAny(Char[])
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 - 1;
   Console::WriteLine( "The last character occurrence  from position {0} to 0.", start );
   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->LastIndexOfAny( anyOf );
   if ( at > -1 )
      Console::Write( at );
   else
      Console::Write( "(not found)" );

   Console::Write( "{0}{0}{0}", Environment::NewLine );
}

/*
This example produces the following results:
The last character occurrence  from position 66 to 0.
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: 58


*/
// Sample for String.LastIndexOfAny(Char[])
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-1;
    Console.WriteLine("The last character occurrence  from position {0} to 0.", start);
    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.LastIndexOfAny(anyOf);
    if (at > -1) 
        Console.Write(at);
    else
        Console.Write("(not found)");
    Console.Write("{0}{0}{0}", Environment.NewLine);
    }
}
/*
This example produces the following results:
The last character occurrence  from position 66 to 0.
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: 58


*/
' Sample for String.LastIndexOfAny(Char[])
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 - 1
      Console.WriteLine("The last character occurrence  from position {0} to 0.", start)
      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.LastIndexOfAny(anyOf)
      If at > - 1 Then
         Console.Write(at)
      Else
         Console.Write("(not found)")
      End If
      Console.Write("{0}{0}{0}", Environment.NewLine)
   End Sub 'Main
End Class 'Sample
'
'This example produces the following results:
'The last character occurrence  from position 66 to 0.
'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: 58
'
'
'

Remarks

인덱스 번호는 0부터 시작합니다.Index numbering starts from zero.

이 메서드는이 인스턴스의 마지막 문자 위치에 있는 검색을 시작 하 고의 문자까지 시작 부분을 향해 뒤로 anyOf 가 찾거나 첫 번째 문자 위치입니다.This method begins searching at the last character position of this instance and proceeds backward toward the beginning until either a character in anyOf is found or the first character position has been examined. 검색은 대/소문자 구분 합니다.The search is case-sensitive.

이 메서드는 유니코드 스칼라 값이 같은 서 수 (문화권) 검색을 수행 합니다.This method performs an ordinal (culture-insensitive) search, where a character is considered equivalent to another character only if their Unicode scalar values are the same. 문화권 구분 검색을 수행 하려면 사용 합니다 CompareInfo.LastIndexOf 메서드, 여기서는 미리 구성 된 문자를 나타내는 합자 "→"와 같은 (U + 00 6), 유니코드 스칼라 값 간주 될 수 있습니다 문자 구성 요소에서의 모든 항목에는 "AE" 등 시퀀스를 수정 (u+0041, U + 0045) 문화권에 따라 합니다.To perform a culture-sensitive search, use the CompareInfo.LastIndexOf method, where a Unicode scalar value representing a precomposed character, such as the ligature "Æ" (U+00C6), might be considered equivalent to any occurrence of the character's components in the correct sequence, such as "AE" (U+0041, U+0045), depending on the culture.

See Also

LastIndexOfAny(Char[], Int32) LastIndexOfAny(Char[], Int32) LastIndexOfAny(Char[], Int32) LastIndexOfAny(Char[], Int32)

유니코드 배열에서 지정된 하나 이상의 문자 중에 이 인스턴스에서 마지막으로 발견되는 문자의 0부터 시작하는 인덱스 위치를 보고합니다. Reports the zero-based index position of the last occurrence in this instance of one or more characters specified in a Unicode array. 지정된 문자 위치에서 시작하고 문자열의 시작 부분을 향해 뒤로 검색이 진행됩니다. The search starts at a specified character position and proceeds backward toward the beginning of the string.

public:
 int LastIndexOfAny(cli::array <char> ^ anyOf, int startIndex);
public int LastIndexOfAny (char[] anyOf, int startIndex);
member this.LastIndexOfAny : char[] * int -> int
Public Function LastIndexOfAny (anyOf As Char(), startIndex As Integer) As Integer

매개 변수

anyOf
Char[]

검색할 문자를 하나 이상 포함하는 유니코드 문자 배열입니다. A Unicode character array containing one or more characters to seek.

startIndex
Int32 Int32 Int32 Int32

검색을 시작할 위치입니다. The search starting position. startIndex에서 이 인스턴스의 시작 부분을 향해 검색이 진행됩니다. The search proceeds from startIndex toward the beginning of this instance.

Returns

이 인스턴스에서 anyOf의 문자가 마지막으로 발견된 인덱스 위치입니다. anyOf의 문자가 발견되지 않거나 현재 인스턴스가 Empty와 동일하면 -1입니다. The index position of the last occurrence in this instance where any character in anyOf was found; -1 if no character in anyOf was found or if the current instance equals Empty.

Exceptions

현재 인스턴스가 Empty와 같지 않고 startIndex가 인스턴스 외부의 위치를 지정합니다. The current instance does not equal Empty, and startIndex specifies a position that is not within this instance.

Examples

다음 예제에서는 다른 문자열의 부분 문자열에 있는 "is" 문자열에 있는 문자 중 마지막 요소의 인덱스를 찾습니다.The following example finds the index of the last occurrence of any character in the string "is" within a substring of another string.

// Sample for String::LastIndexOfAny(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 - 1) / 2;
   Console::WriteLine( "The last character occurrence  from position {0} to 0.", start );
   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->LastIndexOfAny( anyOf, start );
   if ( at > -1 )
      Console::Write( at );
   else
      Console::Write( "(not found)" );

   Console::Write( "{0}{0}{0}", Environment::NewLine );
}

/*
This example produces the following results:
The last character occurrence  from position 33 to 0.
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: 12


*/
// Sample for String.LastIndexOfAny(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-1)/2;
    Console.WriteLine("The last character occurrence  from position {0} to 0.", start);
    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.LastIndexOfAny(anyOf, start);
    if (at > -1) 
        Console.Write(at);
    else
        Console.Write("(not found)");
    Console.Write("{0}{0}{0}", Environment.NewLine);
    }
}
/*
This example produces the following results:
The last character occurrence  from position 33 to 0.
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: 12


*/
' Sample for String.LastIndexOfAny(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 - 1) / 2
      Console.WriteLine("The last character occurrence  from position {0} to 0.", start)
      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.LastIndexOfAny(anyOf, start)
      If at > - 1 Then
         Console.Write(at)
      Else
         Console.Write("(not found)")
      End If
      Console.Write("{0}{0}{0}", Environment.NewLine)
   End Sub 'Main
End Class 'Sample
'
'This example produces the following results:
'The last character occurrence  from position 33 to 0.
'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: 12
'
'
'

Remarks

인덱스 번호는 0부터 시작합니다.Index numbering starts from zero.

이 메서드 검색을 시작 합니다 startIndex 문자이 인스턴스의 위치에 문자가 올 때까지 뒤로 anyOf 가 찾거나 첫 번째 문자 위치입니다.This method begins searching at the startIndex character position of this instance and proceeds backward toward the beginning until either a character in anyOf is found or the first character position has been examined. 검색은 대/소문자 구분 합니다.The search is case-sensitive.

이 메서드는 유니코드 스칼라 값이 같은 서 수 (문화권) 검색을 수행 합니다.This method performs an ordinal (culture-insensitive) search, where a character is considered equivalent to another character only if their Unicode scalar values are the same. 문화권 구분 검색을 수행 하려면 사용 합니다 CompareInfo.LastIndexOf 메서드, 여기서는 미리 구성 된 문자를 나타내는 합자 "→"와 같은 (U + 00 6), 유니코드 스칼라 값 간주 될 수 있습니다 문자 구성 요소에서의 모든 항목에는 "AE" 등 시퀀스를 수정 (u+0041, U + 0045) 문화권에 따라 합니다.To perform a culture-sensitive search, use the CompareInfo.LastIndexOf method, where a Unicode scalar value representing a precomposed character, such as the ligature "Æ" (U+00C6), might be considered equivalent to any occurrence of the character's components in the correct sequence, such as "AE" (U+0041, U+0045), depending on the culture.

See Also

LastIndexOfAny(Char[], Int32, Int32) LastIndexOfAny(Char[], Int32, Int32) LastIndexOfAny(Char[], Int32, Int32) LastIndexOfAny(Char[], Int32, Int32)

유니코드 배열에서 지정된 하나 이상의 문자 중에 이 인스턴스에서 마지막으로 발견되는 문자의 0부터 시작하는 인덱스 위치를 보고합니다. Reports the zero-based index position of the last occurrence in this instance of one or more characters specified in a Unicode array. 지정된 문자 위치에서 검색을 시작하여 지정된 수의 문자 위치에 대한 문자열의 시작 부분 쪽으로 뒤로 검색합니다. The search starts at a specified character position and proceeds backward toward the beginning of the string for a specified number of character positions.

public:
 int LastIndexOfAny(cli::array <char> ^ anyOf, int startIndex, int count);
public int LastIndexOfAny (char[] anyOf, int startIndex, int count);
member this.LastIndexOfAny : char[] * int * int -> int
Public Function LastIndexOfAny (anyOf As Char(), startIndex As Integer, count As Integer) As Integer

매개 변수

anyOf
Char[]

검색할 문자를 하나 이상 포함하는 유니코드 문자 배열입니다. A Unicode character array containing one or more characters to seek.

startIndex
Int32 Int32 Int32 Int32

검색을 시작할 위치입니다. The search starting position. startIndex에서 이 인스턴스의 시작 부분을 향해 검색이 진행됩니다. The search proceeds from startIndex toward the beginning of this instance.

count
Int32 Int32 Int32 Int32

검사할 문자 위치의 수입니다. The number of character positions to examine.

Returns

이 인스턴스에서 anyOf의 문자가 마지막으로 발견된 인덱스 위치입니다. anyOf의 문자가 발견되지 않거나 현재 인스턴스가 Empty와 동일하면 -1입니다. The index position of the last occurrence in this instance where any character in anyOf was found; -1 if no character in anyOf was found or if the current instance equals Empty.

Exceptions

현재 인스턴스가 Empty 같지 않고 count 또는 startIndex가 음수입니다. The current instance does not equal Empty, and count or startIndex is negative. 또는 -or- 현재 인스턴스가 Empty와 같지 않고 startIndex - count + 1이 음수입니다. The current instance does not equal Empty, and startIndex minus count + 1 is less than zero.

Examples

다음 예제에서는 다른 문자열의 부분 문자열에 있는 문자열 "참조"에 있는 문자 중 마지막 요소의 인덱스를 찾습니다.The following example finds the index of the last occurrence of any character in the string "aid" within a substring of another string.

// Sample for String::LastIndexOfAny(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) * 2) / 3;
   count = (str->Length - 1) / 3;
   Console::WriteLine( "The last 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->LastIndexOfAny( anyOf, start, count );
   if ( at > -1 )
      Console::Write( at );
   else
      Console::Write( "(not found)" );

   Console::Write( "{0}{0}{0}", Environment::NewLine );
}

/*
This example produces the following results:
The last character occurrence from position 44 for 22 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.LastIndexOfAny(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)*2)/3;
    count = (str.Length-1)/3;
    Console.WriteLine("The last 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.LastIndexOfAny(anyOf, start, count);
    if (at > -1) 
        Console.Write(at);
    else
        Console.Write("(not found)");
    Console.Write("{0}{0}{0}", Environment.NewLine);
    }
}
/*
This example produces the following results:
The last character occurrence from position 44 for 22 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.LastIndexOfAny(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) * 2 / 3
      count =(str.Length - 1) / 3
      Console.WriteLine("The last 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.LastIndexOfAny(anyOf, start, count)
      If at > - 1 Then
         Console.Write(at)
      Else
         Console.Write("(not found)")
      End If
      Console.Write("{0}{0}{0}", Environment.NewLine)
   End Sub 'Main
End Class 'Sample
'
'This example produces the following results:
'The last character occurrence from position 44 for 22 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
'

Remarks

인덱스 번호는 0부터 시작합니다.Index numbering starts from zero.

이 메서드 검색을 시작 합니다 startIndex 문자이 인스턴스의 위치에 문자가 올 때까지 뒤로 anyOf 가 또는 count 문자 위치를 검토 합니다.This method begins searching at the startIndex character position of this instance and proceeds backward toward the beginning until either a character in anyOf is found or count character positions have been examined. 검색은 대/소문자 구분 합니다.The search is case-sensitive.

이 메서드는 유니코드 스칼라 값이 같은 서 수 (문화권) 검색을 수행 합니다.This method performs an ordinal (culture-insensitive) search, where a character is considered equivalent to another character only if their Unicode scalar values are the same. 문화권 구분 검색을 수행 하려면 사용 합니다 CompareInfo.LastIndexOf 메서드, 여기서는 미리 구성 된 문자를 나타내는 합자 "→"와 같은 (U + 00 6), 유니코드 스칼라 값 간주 될 수 있습니다 문자 구성 요소에서의 모든 항목에는 "AE" 등 시퀀스를 수정 (u+0041, U + 0045) 문화권에 따라 합니다.To perform a culture-sensitive search, use the CompareInfo.LastIndexOf method, where a Unicode scalar value representing a precomposed character, such as the ligature "Æ" (U+00C6), might be considered equivalent to any occurrence of the character's components in the correct sequence, such as "AE" (U+0041, U+0045), depending on the culture.

See Also

Applies to