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

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

An example show you how to check if a string starts with a specific text.

using System;

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

            string str = "The quick brown";
            if (text.StartsWith(str))
            {
                Console.WriteLine("Text starts 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

Network Sites

Statistics

Locations of visitors to this page