C# String EndsWith(String)

Description

String EndsWith(String) determines whether the end of this string instance matches the specified string.

Syntax

String.EndsWith(String) has the following syntax.


public bool EndsWith(
  string value
)

Parameters

String.EndsWith(String) has the following parameters.

  • value - The string to compare to the substring at the end of this instance.

Returns

String.EndsWith(String) method returns true if value matches the end of this instance; otherwise, false.

Example

The following example demonstrates how you can use the EndsWith method.


/*ww  w . j a  va  2s  . c o m*/
using System;

public class EndsWithTest {
    public static void Main() {
       Console.WriteLine("<>".EndsWith(">"));
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version