snippets / icomparable

All snippets tagged icomparable (1)

  1. Array compare / Comparaison de tableau

    Return true for match, else false Retourn true en cas d'egalité sinon false

     1          public static bool compare<T>(ICollection<T> tabA, ICollection<T> tabB) where T : IComparable
    2 {
    3 System.Diagnostics.Debug.Assert(tabA != null);
    4 System.Diagnostics.Debug.Assert(tabB != null);
    5
    6 if ( tabA.Count != tabB.Count)
    7 return false;
    8
    9 IEnumerator<T> enumA = tabA.GetEnumerator();
    10 IEnumerator<T> enumB = tabB.GetEnumerator();
    11 while ( enumA.MoveNext() && enumB.MoveNext() )
    12 {
    13 if ( enumA.Current.CompareTo(enumB.Current) != 0 )
    14 return false;
    15 }
    16 return true;
    17 }
    Posted by themadmax to c# array compare icomparable template ... saved by 1 person ... 0 comments ... 9 months, 1 week
showing 10, 25, 50 items per pages

Pages : 1

Flux RSS friendsnippetLatest snippets


More...