CompareInfo.IsSuffix Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Bestimmt, ob eine Zeichenfolge mit einem bestimmten Suffix endet.
Überlädt
| Name | Beschreibung |
|---|---|
| IsSuffix(String, String) |
Bestimmt, ob die angegebene Quellzeichenfolge mit dem angegebenen Suffix endet. |
| IsSuffix(ReadOnlySpan<Char>, ReadOnlySpan<Char>, CompareOptions) |
Bestimmt, ob ein schreibgeschützter Bereich von Zeichen mit einem bestimmten Suffix endet. |
| IsSuffix(String, String, CompareOptions) |
Bestimmt, ob die angegebene Quellzeichenfolge mit dem angegebenen Suffix mit dem angegebenen CompareOptions Wert endet. |
| IsSuffix(ReadOnlySpan<Char>, ReadOnlySpan<Char>, CompareOptions, Int32) |
Bestimmt, ob eine Zeichenfolge mit einem bestimmten Suffix endet. |
IsSuffix(String, String)
- Quelle:
- CompareInfo.cs
- Quelle:
- CompareInfo.cs
- Quelle:
- CompareInfo.cs
- Quelle:
- CompareInfo.cs
- Quelle:
- CompareInfo.cs
Bestimmt, ob die angegebene Quellzeichenfolge mit dem angegebenen Suffix endet.
public:
virtual bool IsSuffix(System::String ^ source, System::String ^ suffix);
public:
bool IsSuffix(System::String ^ source, System::String ^ suffix);
public virtual bool IsSuffix(string source, string suffix);
public bool IsSuffix(string source, string suffix);
abstract member IsSuffix : string * string -> bool
override this.IsSuffix : string * string -> bool
member this.IsSuffix : string * string -> bool
Public Overridable Function IsSuffix (source As String, suffix As String) As Boolean
Public Function IsSuffix (source As String, suffix As String) As Boolean
Parameter
- source
- String
Die zu durchsuchende Zeichenfolge.
- suffix
- String
Die zu vergleichende Zeichenfolge mit dem Ende von source.
Gibt zurück
truewenn die Länge suffix kleiner oder gleich der Länge von source und source endet mit suffix; andernfalls . false
Ausnahmen
Beispiele
Im folgenden Beispiel wird ermittelt, ob eine Zeichenfolge das Präfix oder Suffix einer anderen Zeichenfolge ist.
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.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
End Class
'This code produces the following output.
'
'IsPrefix( calle, lle ) : False
'IsPrefix( llegar, lle ) : True
'IsSuffix( calle, lle ) : True
'IsSuffix( llegar, lle ) : False
Hinweise
Jede Zeichenfolge beginnt und endet mit einer leeren Teilzeichenfolge (""); Wenn suffix es sich um eine leere Zeichenfolge handelt, gibt diese Methode daher zurück true.
Note
Wenn möglich, sollten Sie Zeichenfolgenvergleichsmethoden aufrufen, die über einen Parameter vom Typ CompareOptions verfügen, um die Art des erwarteten Vergleichs anzugeben. Verwenden Sie in der Regel linguistische Optionen (unter Verwendung der aktuellen Kultur), um Zeichenfolgen zu vergleichen, die auf der Benutzeroberfläche angezeigt werden, und geben CompareOptions.Ordinal Oder CompareOptions.OrdinalIgnoreCase für Sicherheitsvergleiche an.
Weitere Informationen
Gilt für:
IsSuffix(ReadOnlySpan<Char>, ReadOnlySpan<Char>, CompareOptions)
- Quelle:
- CompareInfo.cs
- Quelle:
- CompareInfo.cs
- Quelle:
- CompareInfo.cs
- Quelle:
- CompareInfo.cs
- Quelle:
- CompareInfo.cs
Bestimmt, ob ein schreibgeschützter Bereich von Zeichen mit einem bestimmten Suffix endet.
public bool IsSuffix(ReadOnlySpan<char> source, ReadOnlySpan<char> suffix, System.Globalization.CompareOptions options = System.Globalization.CompareOptions.None);
member this.IsSuffix : ReadOnlySpan<char> * ReadOnlySpan<char> * System.Globalization.CompareOptions -> bool
Public Function IsSuffix (source As ReadOnlySpan(Of Char), suffix As ReadOnlySpan(Of Char), Optional options As CompareOptions = System.Globalization.CompareOptions.None) As Boolean
Parameter
- source
- ReadOnlySpan<Char>
Der schreibgeschützte Bereich von Zeichen, innerhalb der gesucht werden soll.
- suffix
- ReadOnlySpan<Char>
Das Suffix zum Abgleichen am Ende von source.
- options
- CompareOptions
Eine optionale Kombination von CompareOptions Enumerationswerten, die während der Übereinstimmung verwendet werden sollen. Der Standardwert ist None.
Gibt zurück
true wenn suffix am Ende von source; andernfalls false.
Ausnahmen
options enthält eine nicht unterstützte Kombination von Flags.
Gilt für:
IsSuffix(String, String, CompareOptions)
- Quelle:
- CompareInfo.cs
- Quelle:
- CompareInfo.cs
- Quelle:
- CompareInfo.cs
- Quelle:
- CompareInfo.cs
- Quelle:
- CompareInfo.cs
Bestimmt, ob die angegebene Quellzeichenfolge mit dem angegebenen Suffix mit dem angegebenen CompareOptions Wert endet.
public:
virtual bool IsSuffix(System::String ^ source, System::String ^ suffix, System::Globalization::CompareOptions options);
public:
bool IsSuffix(System::String ^ source, System::String ^ suffix, System::Globalization::CompareOptions options);
public virtual bool IsSuffix(string source, string suffix, System.Globalization.CompareOptions options);
public 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
member this.IsSuffix : string * string * System.Globalization.CompareOptions -> bool
Public Overridable Function IsSuffix (source As String, suffix As String, options As CompareOptions) As Boolean
Public Function IsSuffix (source As String, suffix As String, options As CompareOptions) As Boolean
Parameter
- source
- String
Die zu durchsuchende Zeichenfolge.
- suffix
- String
Die zu vergleichende Zeichenfolge mit dem Ende von source.
- options
- CompareOptions
Ein Wert, der definiert, wie source und suffix wie verglichen werden soll.
optionsist entweder der von sich selbst verwendete Enumerationswert Ordinal oder die bitweise Kombination aus einem oder mehreren der folgenden Werte: IgnoreCase, , , IgnoreSymbolsIgnoreNonSpace, IgnoreWidthund IgnoreKanaType.
Gibt zurück
truewenn die Länge suffix kleiner oder gleich der Länge von source und source endet mit suffix; andernfalls . false
Ausnahmen
options enthält einen ungültigen CompareOptions Wert.
Beispiele
Im folgenden Beispiel wird ermittelt, ob es sich bei einer Zeichenfolge um das Präfix oder Suffix einer anderen Zeichenfolge handelt.CompareOptions
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.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
End Class
'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
Hinweise
Jede Zeichenfolge beginnt und endet mit einer leeren Teilzeichenfolge (""); Wenn suffix es sich um eine leere Zeichenfolge handelt, gibt diese Methode daher zurück true.
Die Werte und CompareOptions.NumericOrdering Werte CompareOptions.StringSort sind für diese Methode ungültig.
Note
Wenn möglich, sollten Sie Zeichenfolgenvergleichsmethoden aufrufen, die über einen Parameter vom Typ CompareOptions verfügen, um die Art des erwarteten Vergleichs anzugeben. Verwenden Sie in der Regel linguistische Optionen (unter Verwendung der aktuellen Kultur), um Zeichenfolgen zu vergleichen, die auf der Benutzeroberfläche angezeigt werden, und geben CompareOptions.Ordinal Oder CompareOptions.OrdinalIgnoreCase für Sicherheitsvergleiche an.
Weitere Informationen
Gilt für:
IsSuffix(ReadOnlySpan<Char>, ReadOnlySpan<Char>, CompareOptions, Int32)
- Quelle:
- CompareInfo.cs
- Quelle:
- CompareInfo.cs
- Quelle:
- CompareInfo.cs
- Quelle:
- CompareInfo.cs
- Quelle:
- CompareInfo.cs
Bestimmt, ob eine Zeichenfolge mit einem bestimmten Suffix endet.
public:
bool IsSuffix(ReadOnlySpan<char> source, ReadOnlySpan<char> suffix, System::Globalization::CompareOptions options, [Runtime::InteropServices::Out] int % matchLength);
public bool IsSuffix(ReadOnlySpan<char> source, ReadOnlySpan<char> suffix, System.Globalization.CompareOptions options, out int matchLength);
member this.IsSuffix : ReadOnlySpan<char> * ReadOnlySpan<char> * System.Globalization.CompareOptions * int -> bool
Public Function IsSuffix (source As ReadOnlySpan(Of Char), suffix As ReadOnlySpan(Of Char), options As CompareOptions, ByRef matchLength As Integer) As Boolean
Parameter
- source
- ReadOnlySpan<Char>
Der schreibgeschützte Bereich von Zeichen, innerhalb der gesucht werden soll.
- suffix
- ReadOnlySpan<Char>
Der schreibgeschützte Bereich von Zeichen, die das Suffix enthalten, um zu versuchen, am Ende von source.
- options
- CompareOptions
Die CompareOptions zu verwendende Während der Übereinstimmung.
- matchLength
- Int32
Wenn diese Methode zurückgegeben wird, enthält die Anzahl der Zeichen, die source dem gewünschten Suffix entsprechen. Dies kann anders sein als die Länge, suffix wenn ein linguistischer Vergleich durchgeführt wird. Wird auf 0 festgelegt, wenn das Suffix nicht übereinstimmt.
Gibt zurück
true wenn suffix am Ende von source; andernfalls false.
Ausnahmen
options enthält eine nicht unterstützte Kombination von Flags.
Hinweise
Diese Methode hat mehr Aufwand als andere IsSuffix(String, String, CompareOptions) Überladungen, die kein Argument annehmen matchLength . Rufen Sie diese Überladung nur auf, wenn Sie die Übereinstimmungslängeninformationen benötigen.