true if value matches the end of this instance; otherwise, false.
Type Reason ArgumentNullException value is a null reference.
This method compares value to the substring at the end of this instance that is the same length as value, and returns an indication whether they are equal. To be equal, value must be a reference to this same instance or match the end of this instance.
This method performs a word (case-sensitive and culture-sensitive) comparison using the current culture.
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'