The C# EndsWith function is employed to verify if the provided string corresponds to the conclusion of this string. When the specified string is located at the end of this string, it will yield true; otherwise, it will return false.
Signature
Example
public bool EndsWith(String str)
public bool EndsWith(String, Boolean, CultureInfo)
public bool EndsWith (String, StringComparison)?
Parameters
str: It represents a string object that is utilized to determine if a particular string ends with it.
Return
It returns boolean value either true or false.
C# String EndsWith Method Example
Example
using System;
public class StringExample
{
public static void Main(string[] args)
{
string s1 = "Hello";
string s2 = "llo";
string s3 = "C#";
Console.WriteLine(s1.EndsWith(s2));
Console.WriteLine(s1.EndsWith(s3));
}
}
Output:
Output
True
False