C# Using Enumerable Range and Except with custom class to determine missing sequence number
- by Jon
I have a List<MyClass>
The class is like this:
private class MyClass
        {
            public string Name{ get; set; }
            public int SequenceNumber { get; set; }
        }
I want to work out what Sequence numbers might be missing.  I can see how to do this here however because this is a class I am unsure what to do?
I think I can handle the except method ok with my own IComparer but the Range method I can't figure out because it only excepts int so this doesn't compile:
Enumerable.Range(0, 1000000).Except(chqList, MyEqualityComparer<MyClass>);
Here is the IComparer:
 public class MyEqualityComparer<T> : IEqualityComparer<T> where T : MyClass
        {
            #region IEqualityComparer<T> Members
            public bool Equals(T x, T y)
            {
                return (x == null && y == null) || (x != null && y != null && x.SequenceNumber.Equals(y.SequenceNumber));
            }
            /// </exception>
            public int GetHashCode(T obj)
            {
                if (obj == null)
                {
                    throw new ArgumentNullException("obj");
                }
                return obj.GetHashCode();
            }
            #endregion
        }