CompareInfo.IsSuffix Method (String, String, CompareOptions)

 

Determines whether the specified source string ends with the specified suffix using the specified CompareOptions value.

Namespace:   System.Globalization
Assembly:  mscorlib (in mscorlib.dll)

abstract IsSuffix : 
        source:string *
        suffix:string *
        options:CompareOptions -> bool
override IsSuffix : 
        source:string *
        suffix:string *
        options:CompareOptions -> bool

Parameters

source
Type: System.String

The string to search in.

suffix
Type: System.String

The string to compare with the end of source.

options
Type: System.Globalization.CompareOptions

A value that defines how source and suffix should be compared. 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.

Return Value

Type: System.Boolean

true if the length of suffix is less than or equal to the length of source and source ends with suffix; otherwise, false.

Exception Condition
ArgumentNullException

source is null.

-or-

suffix is null.

ArgumentException

options contains an invalid CompareOptions value.

Every string starts and ends with an empty substring (""); therefore, if suffix is an empty string, this method returns true.

The CompareOptions.StringSort value is not valid for this method.

System_CAPS_noteNote

When possible, you should call string comparison methods that have a parameter of type CompareOptions to specify the kind of comparison expected. 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.

The following example determines whether a string is the prefix or suffix of another string using CompareOptions.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
Show: