Mono Class Library: System.String Overview | MembersSystem.String.EndsWith Method |
Returns a bool value that indicates whether the ending characters of the current instance match the specified string. [Edit]
|
true if the end of the current instance is equal to value; false if value is not equal to the end of the current instance or is longer than the current instance. [Edit]
Type Reason ArgumentNullException value is a null reference. [Edit]
This method compares value with the substring at the end of the current instance that has a same length as value.
The comparison is case-sensitive.
[Edit]
The following example demonstrates determining whether the current instance ends with a specified string.
C# Example using System; public class StringEndsWithExample { public static void Main() { string str = "One string to compare"; Console.WriteLine( "The given string is '{0}'", str ); Console.Write( "The given string ends with 'compare'? " ); Console.WriteLine( str.EndsWith( "compare" ) ); Console.Write( "The given string ends with 'Compare'? " ); Console.WriteLine( str.EndsWith( "Compare" ) ); } }The output is
The given string is 'One string to compare'
The given string ends with 'compare'? True
The given string ends with 'Compare'? False
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0