Check int Array Equals - CSharp System

CSharp examples for System:Array Equal

Description

Check int Array Equals

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;/*from  w w w . jav a2 s.c  om*/

public class Main{
        public static void CheckArrayEquals( int[] left, int[] right )
        {
            bool good = false;

            try
            {
                if( left.Length != right.Length )
                {
                    return;
                }

                for( int i = 0; i < left.Length; i++ )
                {
                    if( left[i] != right[i] )
                    {
                        return;
                    }
                }

                good = true;
            }
            finally
            {
                if( good == false )
                {
                    throw new Exception();
                }
            }
        }
        public static void CheckArrayEquals( byte[] left, byte[] right )
        {
            bool good = false;

            try
            {
                if( left.Length != right.Length )
                {
                    return;
                }

                for( int i = 0; i < left.Length; i++ )
                {
                    if( left[i] != right[i] )
                    {
                        return;
                    }
                }

                good = true;
            }
            finally
            {
                if( good == false )
                {
                    throw new Exception();
                }
            }
        }
}

Related Tutorials