CompareInfo.IsSuffix CompareInfo.IsSuffix CompareInfo.IsSuffix CompareInfo.IsSuffix Method

정의

문자열이 지정된 접미사로 끝나는지 여부를 확인합니다.Determines whether a string ends with a specific suffix.

오버로드

IsSuffix(String, String) IsSuffix(String, String) IsSuffix(String, String) IsSuffix(String, String)

지정된 소스 문자열이 지정된 접미사로 끝나는지 여부를 확인합니다.Determines whether the specified source string ends with the specified suffix.

IsSuffix(String, String, CompareOptions) IsSuffix(String, String, CompareOptions) IsSuffix(String, String, CompareOptions) IsSuffix(String, String, CompareOptions)

지정된 CompareOptions 값을 사용하여 지정된 소스 문자열이 지정된 접미사로 끝나는지 여부를 확인합니다.Determines whether the specified source string ends with the specified suffix using the specified CompareOptions value.

IsSuffix(String, String) IsSuffix(String, String) IsSuffix(String, String) IsSuffix(String, String)

지정된 소스 문자열이 지정된 접미사로 끝나는지 여부를 확인합니다.Determines whether the specified source string ends with the specified suffix.

public:
 virtual bool IsSuffix(System::String ^ source, System::String ^ suffix);
public virtual bool IsSuffix (string source, string suffix);
abstract member IsSuffix : string * string -> bool
override this.IsSuffix : string * string -> bool
Public Overridable Function IsSuffix (source As String, suffix As String) As Boolean

매개 변수

source
String String String String

검색할 문자열입니다.The string to search in.

suffix
String String String String

source의 끝 영역과 비교할 문자열입니다.The string to compare with the end of source.

반환

suffix의 길이가 source로 끝나는 sourcesuffix의 길이보다 작거나 같으면 true이고, 그렇지 않으면 false입니다.true if the length of suffix is less than or equal to the length of source and source ends with suffix; otherwise, false.

예외

sourcenull입니다.source is null.

또는-or- suffixnull입니다.suffix is null.

예제

다음 예제에서는 접두사 또는 접미사 다른 문자열의 문자열 인지 확인 합니다.The following example determines whether a string is the prefix or suffix of another string.

using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Defines the strings to compare.
   String^ myStr1 = "calle";
   String^ myStr2 = "llegar";
   String^ myXfix = "lle";
   
   // Uses the CompareInfo property of the InvariantCulture.
   CompareInfo^ myComp = CultureInfo::InvariantCulture->CompareInfo;
   
   // Determines whether myXfix is a prefix of S"calle" and S"llegar".
   Console::WriteLine( "IsPrefix( {0}, {1}) : {2}", myStr1, myXfix, myComp->IsPrefix( myStr1, myXfix ) );
   Console::WriteLine( "IsPrefix( {0}, {1}) : {2}", myStr2, myXfix, myComp->IsPrefix( myStr2, myXfix ) );
   
   // Determines whether myXfix is a suffix of S"calle" and S"llegar".
   Console::WriteLine( "IsSuffix( {0}, {1}) : {2}", myStr1, myXfix, myComp->IsSuffix( myStr1, myXfix ) );
   Console::WriteLine( "IsSuffix( {0}, {1}) : {2}", myStr2, myXfix, myComp->IsSuffix( myStr2, myXfix ) );
}

/*
This code produces the following output.

IsPrefix(calle, lle) : False
IsPrefix(llegar, lle) : True
IsSuffix(calle, lle) : True
IsSuffix(llegar, lle) : False

*/
using System;
using System.Globalization;

public class SamplesCompareInfo  {

   public static void Main()  {

      // Defines the strings to compare.
      String myStr1 = "calle";
      String myStr2 = "llegar";
      String myXfix = "lle";

      // Uses the CompareInfo property of the InvariantCulture.
      CompareInfo myComp = CultureInfo.InvariantCulture.CompareInfo;

      // Determines whether myXfix is a prefix of "calle" and "llegar".
      Console.WriteLine( "IsPrefix( {0}, {1} ) : {2}", myStr1, myXfix, myComp.IsPrefix( myStr1, myXfix ) );
      Console.WriteLine( "IsPrefix( {0}, {1} ) : {2}", myStr2, myXfix, myComp.IsPrefix( myStr2, myXfix ) );

      // Determines whether myXfix is a suffix of "calle" and "llegar".
      Console.WriteLine( "IsSuffix( {0}, {1} ) : {2}", myStr1, myXfix, myComp.IsSuffix( myStr1, myXfix ) );
      Console.WriteLine( "IsSuffix( {0}, {1} ) : {2}", myStr2, myXfix, myComp.IsSuffix( myStr2, myXfix ) );

   }

}


/*
This code produces the following output.

IsPrefix( calle, lle ) : False
IsPrefix( llegar, lle ) : True
IsSuffix( calle, lle ) : True
IsSuffix( llegar, lle ) : False

*/
Imports System
Imports System.Globalization

Public Class SamplesCompareInfo

   Public Shared Sub Main()

      ' Defines the strings to compare.
      Dim myStr1 As [String] = "calle"
      Dim myStr2 As [String] = "llegar"
      Dim myXfix As [String] = "lle"

      ' Uses the CompareInfo property of the InvariantCulture.
      Dim myComp As CompareInfo = CultureInfo.InvariantCulture.CompareInfo

      ' Determines whether myXfix is a prefix of "calle" and "llegar".
      Console.WriteLine("IsPrefix( {0}, {1} ) : {2}", myStr1, myXfix, myComp.IsPrefix(myStr1, myXfix))
      Console.WriteLine("IsPrefix( {0}, {1} ) : {2}", myStr2, myXfix, myComp.IsPrefix(myStr2, myXfix))

      ' Determines whether myXfix is a suffix of "calle" and "llegar".
      Console.WriteLine("IsSuffix( {0}, {1} ) : {2}", myStr1, myXfix, myComp.IsSuffix(myStr1, myXfix))
      Console.WriteLine("IsSuffix( {0}, {1} ) : {2}", myStr2, myXfix, myComp.IsSuffix(myStr2, myXfix))

   End Sub 'Main 

End Class 'SamplesCompareInfo


'This code produces the following output.
'
'IsPrefix( calle, lle ) : False
'IsPrefix( llegar, lle ) : True
'IsSuffix( calle, lle ) : True
'IsSuffix( llegar, lle ) : False

설명

모든 문자열 시작 끝나며 빈 부분 문자열 (""); 따라서 경우 suffix 이 빈 문자열인 경우이 메서드는 반환 true합니다.Every string starts and ends with an empty substring (""); therefore, if suffix is an empty string, this method returns true.

참고

가능한 경우 메서드를 호출 해야 문자열 비교의 형식 매개 변수가 있는 CompareOptions 예상 비교의 종류를 지정 합니다.When possible, you should call string comparison methods that have a parameter of type CompareOptions to specify the kind of comparison expected. 일반적으로 사용자 인터페이스에 표시 되는 문자열을 비교 하기 위한 언어 옵션 (현재 문화권을 사용한)를 사용 하 고 지정 CompareOptions.Ordinal 또는 CompareOptions.OrdinalIgnoreCase 보안을 비교 합니다.As a general rule, use linguistic options (using the current culture) for comparing strings displayed in the user interface and specify CompareOptions.Ordinal or CompareOptions.OrdinalIgnoreCase for security comparisons.

추가 정보

IsSuffix(String, String, CompareOptions) IsSuffix(String, String, CompareOptions) IsSuffix(String, String, CompareOptions) IsSuffix(String, String, CompareOptions)

지정된 CompareOptions 값을 사용하여 지정된 소스 문자열이 지정된 접미사로 끝나는지 여부를 확인합니다.Determines whether the specified source string ends with the specified suffix using the specified CompareOptions value.

public:
 virtual bool IsSuffix(System::String ^ source, System::String ^ suffix, System::Globalization::CompareOptions options);
public virtual bool IsSuffix (string source, string suffix, System.Globalization.CompareOptions options);
abstract member IsSuffix : string * string * System.Globalization.CompareOptions -> bool
override this.IsSuffix : string * string * System.Globalization.CompareOptions -> bool
Public Overridable Function IsSuffix (source As String, suffix As String, options As CompareOptions) As Boolean

매개 변수

source
String String String String

검색할 문자열입니다.The string to search in.

suffix
String String String String

source의 끝 영역과 비교할 문자열입니다.The string to compare with the end of source.

options
CompareOptions CompareOptions CompareOptions CompareOptions

sourcesuffix을 비교하는 방법을 정의하는 값입니다.A value that defines how source and suffix should be compared. options는 자체적으로 사용하는 열거형 값 Ordinal이거나 IgnoreCase, IgnoreSymbols, IgnoreNonSpace, IgnoreWidthIgnoreKanaType 값 중 하나 이상의 비트 조합입니다.options is either the enumeration value Ordinal used by itself, or the bitwise combination of one or more of the following values: IgnoreCase, IgnoreSymbols, IgnoreNonSpace, IgnoreWidth, and IgnoreKanaType.

반환

suffix의 길이가 source로 끝나는 sourcesuffix의 길이보다 작거나 같으면 true이고, 그렇지 않으면 false입니다.true if the length of suffix is less than or equal to the length of source and source ends with suffix; otherwise, false.

예외

sourcenull입니다.source is null.

또는-or- suffixnull입니다.suffix is null.

options에 잘못된 CompareOptions 값이 포함된 경우options contains an invalid CompareOptions value.

예제

다음 예제에서는 접두사 또는 접미사를 사용 하 여 다른 문자열의 문자열 인지를 확인 CompareOptions합니다.The following example determines whether a string is the prefix or suffix of another string using CompareOptions.

using namespace System;
using namespace System::Globalization;
int main()
{
   
   // Defines the strings to compare.
   String^ myStr1 = "calle";
   String^ myStr2 = "llegar";
   String^ myXfix = "LLE";
   
   // Uses the CompareInfo property of the InvariantCulture.
   CompareInfo^ myComp = CultureInfo::InvariantCulture->CompareInfo;
   Console::WriteLine( "IsSuffix \"{0}\", \"{1}\"", myStr1, myXfix );
   Console::WriteLine( "   With no CompareOptions            : {0}", myComp->IsSuffix( myStr1, myXfix ) );
   Console::WriteLine( "   With None                         : {0}", myComp->IsSuffix( myStr1, myXfix, CompareOptions::None ) );
   Console::WriteLine( "   With Ordinal                      : {0}", myComp->IsSuffix( myStr1, myXfix, CompareOptions::Ordinal ) );
   Console::WriteLine( "   With IgnoreCase                   : {0}", myComp->IsSuffix( myStr1, myXfix, CompareOptions::IgnoreCase ) );
   Console::WriteLine( "IsPrefix \"{0}\", \"{1}\"", myStr2, myXfix );
   Console::WriteLine( "   With no CompareOptions            : {0}", myComp->IsPrefix( myStr2, myXfix ) );
   Console::WriteLine( "   With None                         : {0}", myComp->IsPrefix( myStr2, myXfix, CompareOptions::None ) );
   Console::WriteLine( "   With Ordinal                      : {0}", myComp->IsPrefix( myStr2, myXfix, CompareOptions::Ordinal ) );
   Console::WriteLine( "   With IgnoreCase                   : {0}", myComp->IsPrefix( myStr2, myXfix, CompareOptions::IgnoreCase ) );
}

/*
This code produces the following output.

IsSuffix "calle", "LLE"
   With no CompareOptions            : False
   With None                         : False
   With Ordinal                      : False
   With IgnoreCase                   : True
IsPrefix "llegar", "LLE"
   With no CompareOptions            : False
   With None                         : False
   With Ordinal                      : False
   With IgnoreCase                   : True
*/
using System;
using System.Globalization;

public class SamplesCompareInfo  {

   public static void Main()  {

      // Defines the strings to compare.
      String myStr1 = "calle";
      String myStr2 = "llegar";
      String myXfix = "LLE";

      // Uses the CompareInfo property of the InvariantCulture.
      CompareInfo myComp = CultureInfo.InvariantCulture.CompareInfo;

      Console.WriteLine( "IsSuffix \"{0}\", \"{1}\"", myStr1, myXfix );
      Console.WriteLine( "   With no CompareOptions            : {0}", myComp.IsSuffix( myStr1, myXfix ) );
      Console.WriteLine( "   With None                         : {0}", myComp.IsSuffix( myStr1, myXfix, CompareOptions.None ) );
      Console.WriteLine( "   With Ordinal                      : {0}", myComp.IsSuffix( myStr1, myXfix, CompareOptions.Ordinal ) );
      Console.WriteLine( "   With IgnoreCase                   : {0}", myComp.IsSuffix( myStr1, myXfix, CompareOptions.IgnoreCase ) );

      Console.WriteLine( "IsPrefix \"{0}\", \"{1}\"", myStr2, myXfix );
      Console.WriteLine( "   With no CompareOptions            : {0}", myComp.IsPrefix( myStr2, myXfix ) );
      Console.WriteLine( "   With None                         : {0}", myComp.IsPrefix( myStr2, myXfix, CompareOptions.None ) );
      Console.WriteLine( "   With Ordinal                      : {0}", myComp.IsPrefix( myStr2, myXfix, CompareOptions.Ordinal ) );
      Console.WriteLine( "   With IgnoreCase                   : {0}", myComp.IsPrefix( myStr2, myXfix, CompareOptions.IgnoreCase ) );

   }

}


/*
This code produces the following output.

IsSuffix "calle", "LLE"
   With no CompareOptions            : False
   With None                         : False
   With Ordinal                      : False
   With IgnoreCase                   : True
IsPrefix "llegar", "LLE"
   With no CompareOptions            : False
   With None                         : False
   With Ordinal                      : False
   With IgnoreCase                   : True

*/
Imports System
Imports System.Globalization

Public Class SamplesCompareInfo

   Public Shared Sub Main()

      ' Defines the strings to compare.
      Dim myStr1 As [String] = "calle"
      Dim myStr2 As [String] = "llegar"
      Dim myXfix As [String] = "LLE"

      ' Uses the CompareInfo property of the InvariantCulture.
      Dim myComp As CompareInfo = CultureInfo.InvariantCulture.CompareInfo

      Console.WriteLine("IsSuffix ""{0}"", ""{1}""", myStr1, myXfix)
      Console.WriteLine("   With no CompareOptions            : {0}", myComp.IsSuffix(myStr1, myXfix))
      Console.WriteLine("   With None                         : {0}", myComp.IsSuffix(myStr1, myXfix, CompareOptions.None))
      Console.WriteLine("   With Ordinal                      : {0}", myComp.IsSuffix(myStr1, myXfix, CompareOptions.Ordinal))
      Console.WriteLine("   With IgnoreCase                   : {0}", myComp.IsSuffix(myStr1, myXfix, CompareOptions.IgnoreCase))

      Console.WriteLine("IsPrefix ""{0}"", ""{1}""", myStr2, myXfix)
      Console.WriteLine("   With no CompareOptions            : {0}", myComp.IsPrefix(myStr2, myXfix))
      Console.WriteLine("   With None                         : {0}", myComp.IsPrefix(myStr2, myXfix, CompareOptions.None))
      Console.WriteLine("   With Ordinal                      : {0}", myComp.IsPrefix(myStr2, myXfix, CompareOptions.Ordinal))
      Console.WriteLine("   With IgnoreCase                   : {0}", myComp.IsPrefix(myStr2, myXfix, CompareOptions.IgnoreCase))

   End Sub 'Main 

End Class 'SamplesCompareInfo


'This code produces the following output.
'
'IsSuffix "calle", "LLE"
'   With no CompareOptions            : False
'   With None                         : False
'   With Ordinal                      : False
'   With IgnoreCase                   : True
'IsPrefix "llegar", "LLE"
'   With no CompareOptions            : False
'   With None                         : False
'   With Ordinal                      : False
'   With IgnoreCase                   : True

설명

모든 문자열 시작 끝나며 빈 부분 문자열 (""); 따라서 경우 suffix 이 빈 문자열인 경우이 메서드는 반환 true합니다.Every string starts and ends with an empty substring (""); therefore, if suffix is an empty string, this method returns true.

CompareOptions.StringSort 값이이 메서드에 대해 올바르지 않습니다.The CompareOptions.StringSort value is not valid for this method.

참고

가능한 경우 메서드를 호출 해야 문자열 비교의 형식 매개 변수가 있는 CompareOptions 예상 비교의 종류를 지정 합니다.When possible, you should call string comparison methods that have a parameter of type CompareOptions to specify the kind of comparison expected. 일반적으로 사용자 인터페이스에 표시 되는 문자열을 비교 하기 위한 언어 옵션 (현재 문화권을 사용한)를 사용 하 고 지정 CompareOptions.Ordinal 또는 CompareOptions.OrdinalIgnoreCase 보안을 비교 합니다.As a general rule, use linguistic options (using the current culture) for comparing strings displayed in the user interface and specify CompareOptions.Ordinal or CompareOptions.OrdinalIgnoreCase for security comparisons.

추가 정보

적용 대상