I have a class that looks like this
public class Foo
{
public int A { get; set; }
public List<string> Bs { get; set; }
}
And a comparer that looks like this
public class FooComparer : IComparer<Foo>
{
public int Compare(Foo x, Foo y)
{
return x.A.CompareTo(y.A);
}
}
I wanted to combine these into one thing but was concerned about this not being good practice or just appearing odd. What are your thoughts on this
public class Foo : IComparer<Foo>
{
public int A { get; set; }
public List<string> Bs { get; set; }
public int Compare(Foo x, Foo y)
{
return x.A.CompareTo(y.A);
}
}