SiteMap  | About    

How to use C# string EndsWith

EndsWith in C# string Class check if the Parameter String EndsWith the Specified String

bool string.EndsWith(string suffix)


suffix - The passing String for it EndsWith


Boolean - Yes/No

If the String EndsWith the Parameter String it returns True

If the String doesn't EndsWith the Parameter String it return False

For ex : "This is a Test".EndsWith("Test") returns True

"This is a Test".EndsWith("is") returns False


System.ArgumentNullException : If the argument is null

using System;
using System.Windows.Forms;

namespace WindowsApplication1
	public partial class Form1 : Form
		public Form1()

		private void button1_Click(object sender, EventArgs e)
			string str = null;
			str = "VB.NET TOP 10 BOOKS";
			if (str.EndsWith("BOOKS") == true)
				MessageBox.Show("The String EndsWith 'BOOKS' ");
				MessageBox.Show("The String does not EndsWith 'BOOKS'");

When you execute the C# program you will get a message box like "The String EndsWith 'BOOKS' " (C) 2016    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.