How to find the first index of a specific character 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++ ada";

            char ch = 'a';

            int i = s.IndexOf(ch);

            Console.WriteLine(i);
        }
    }
}


/*
run:
     
1

*/

 



answered Dec 25, 2016 by avibootz
...