In this source code example, we will demonstrate the usage of String.EndsWith() method in C# with an example.
The C# String.EndsWith() method is used to check whether the specified string matches the end of this string or not. If the specified string is found at the end of this string, it returns true otherwise false.C# String EndsWith Method Example
The following example demonstrates the String.EndsWith() method:
using System;
public class StringDemo
{
public static void Main(string[] args)
{
string s1 = "sourcecodeexamples";
string s2 = "code";
string s3 = "examples";
Console.WriteLine(s1.EndsWith(s2));
Console.WriteLine(s1.EndsWith(s3));
}
}
Output:
False
True
Related C# String Examples
- C# String Clone Method Example
- C# String Compare Method Example
- C# String CompareTo Method Example
- C# String Concat Method Example
- C# String Contains Method Example
- C# String Copy Method Example
- C# String CopyTo Method Example
- C# String EndsWith Method Example
- C# String Equals Method Example
- C# String GetEnumerator Method Example
- C# String GetHashCode Method Example
- C# String IndexOf Method Example
- C# String Insert Method Example
- C# String Intern Method Example
- C# String IsNullOrEmpty Method Example
- C# String IsNullOrWhiteSpace Method Example
- C# String LastIndexOf Method Example
- C# String Clone Method Example
- C# String Compare Method Example
- C# String CompareTo Method Example
- C# String Concat Method Example
- C# String Contains Method Example
- C# String Copy Method Example
- C# String CopyTo Method Example
- C# String EndsWith Method Example
- C# String Equals Method Example
- C# String GetEnumerator Method Example
- C# String GetHashCode Method Example
- C# String IndexOf Method Example
- C# String Insert Method Example
- C# String Intern Method Example
- C# String IsNullOrEmpty Method Example
- C# String IsNullOrWhiteSpace Method Example
- C# String LastIndexOf Method Example
References
https://docs.microsoft.com/en-us/dotnet/api/system.string.endswith?view=net-6.0
Comments
Post a Comment