How do I check if string ends with a specific text?

Category: System, viewed: 829 time(s).

An example to check if a string ends with a specific text.

using System;

namespace Kodecsharp.Example.System
{
    public class EndWith
    {
        public static void Main(string[] args) {
            string text = "The quick brown fox jumps over the lazy dog";

            string str = "lazy dog";
            if (text.EndsWith(str))
            {
                Console.WriteLine("Text ends with " + str);
            }

            Console.ReadLine();
        }
    }
}
Download Hundreds of Complimentary Industry Resources

Get hundreds of popular Industry magazines, white papers, webinars, podcasts, and more; all available at no cost to you. With more than 600 complimentary offers, you'll find plenty of titles to suit your professional interests and needs. Click Here and Sign up today!

Our Friends

Statistics

Locations of visitors to this page