![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
EndsWith() Method in C#
The EndsWith() method in C# is used to check whether the ending of the current string instance matches with a specified string or not.
Syntax
Following is the syntax −
public bool EndsWith(string str)
Above, the str parameter is the string to be compared.
Example
Let us now see an example to implement the EndsWith() method −
using System; public class Demo{ public static void Main(){ bool val; string str = "demo$"; val = str.EndsWith("$"); Console.WriteLine("Return Value = "+val.ToString()); } }
Output
This will produce the following output −
Return Value = True
Example
Let us now see another example to implement the EndsWith() method −
using System; public class Demo{ public static void Main(){ bool val; string str = "mytext@"; val = str.EndsWith("#"); Console.WriteLine("Return Value = "+val.ToString()); } }
Output
This will produce the following output −
Return Value = False
Advertisements