Compare two char arrays. No null checks are performed. - CSharp System

CSharp examples for System:Char

Description

Compare two char arrays. No null checks are performed.

Demo Code


using System;/* w  ww  . j  a  va 2 s  . co m*/

public class Main{
        /// <summary>
        /// Compare two char arrays. No null checks are performed.
        /// </summary>
        /// 
        /// <param name="A">The char byte array</param>
        /// <param name="B">The second char array</param>
        /// 
        /// <returns>The result of the comparison</returns>
        public static bool Equals(char[] A, char[] B)
        {
            if (A.Length != B.Length)
                return false;

            for (int i = A.Length - 1; i >= 0; i--)
            {
                if (A[i] != B[i])
                    return false;
            }
            
            return true;
        }
}

Related Tutorials