How to use IndexOf() to search for a substring in a string with C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    class Program
    {
        public int Length { get; private set; }

        static void Main(string[] args)
        {
            const string s = "java c# c++";

            if (s.IndexOf("c#") != -1)
                Console.WriteLine("yes");
            else
                Console.WriteLine("no");
        }
    }
}


/*
run:
     
yes

*/

 



answered Dec 24, 2016 by avibootz
edited Dec 25, 2016 by avibootz

Related questions

1 answer 170 views
1 answer 157 views
2 answers 206 views
1 answer 222 views
222 views asked Dec 25, 2016 by avibootz
2 answers 206 views
...