How to check if the first part of string start with specific substring in C#

2 Answers

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = "c# modern programming";

            if (s.StartsWith("c#"))
                Console.WriteLine("yes");
            else
                Console.WriteLine("yes");
        }
    }
}


/*
run:
     
yes
 
*/

 



answered Dec 23, 2016 by avibootz
0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = "http://www.collectivesolver.com/";

            if (s.StartsWith("http://") || s.StartsWith("https://"))
                Console.WriteLine("yes");
            else
                Console.WriteLine("yes");
        }
    }
}


/*
run:
     
yes
 
*/

 



answered Dec 23, 2016 by avibootz

Related questions

...