C# String EndsWith(String, Boolean, CultureInfo)

Description

String EndsWith(String, Boolean, CultureInfo) determines whether the end of this string instance matches the specified string when compared using the specified culture.

Syntax

String.EndsWith(String, Boolean, CultureInfo) has the following syntax.


public bool EndsWith(
  string value,//from  w ww  . ja  v  a  2s.  c o m
  bool ignoreCase,
  CultureInfo culture
)

Parameters

String.EndsWith(String, Boolean, CultureInfo) has the following parameters.

  • value - The string to compare to the substring at the end of this instance.
  • ignoreCase - true to ignore case during the comparison; otherwise, false.
  • culture - Cultural information that determines how this instance and value are compared. If culture is null, the current culture is used.

Returns

String.EndsWith(String, Boolean, CultureInfo) method returns true if the value parameter matches the end of this string; otherwise, false.

Example

The following example determines whether a string occurs at the end of another string.


/*from   ww w.ja va2s. c o  m*/
using System;
using System.Threading;
using System.Globalization;

class Sample 
{
    public static void Main() 
    {
        bool result = false;
        CultureInfo ci;
    
        string capitalARing = "\u00c5";
        string xyzARing = "xyz" + "\u0061\u030a";
    
        ci = new CultureInfo("en-US");
    
        result = xyzARing.EndsWith(capitalARing, false, ci);
        Console.WriteLine(result);
    
        Console.WriteLine("Case insensitive:");
        result = xyzARing.EndsWith(capitalARing, true, ci);
        Console.WriteLine(result);
    }
}

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