Index Of char in char array - CSharp System

CSharp examples for System:Array Index

Description

Index Of char in char array

Demo Code


using System;// ww w  .  j  av a2s .  co m

public class Main{
        public static Int32 IndexOf(this Char[] charHelper, Char value)
        {
            var count = 0;
            for (int index = 0; index < charHelper.Length; index++)
            {
                if (charHelper[index] == value)
                    break;
                count++;
            }

            if (count == charHelper.Length)
                count = -1;
            return count;
        }
}

Related Tutorials