Get Hash Code from Array class - CSharp System

CSharp examples for System:Array Calculation

Description

Get Hash Code from Array class

Demo Code


using System.Collections.Generic;
using System;/*from  w  w  w .ja  v a2s. co  m*/

public class Main{
        public static Int32 GetHashCode(Array array)
    {
      if (array == null) return 0;
      Int32 code = 0;
      for (var i = 0; i < array.Length; ++i)
      {
        object value = array.GetValue(i);
        if (value != null)
        {
          code ^= value.GetHashCode();
        }
      }
      return code;
    }
}

Related Tutorials