I know this is probably a really simple question but I'm having a brain fart at the moment. I am trying to create a method that can take one of 2 custom types. Basically the body of this method will be identical for both the types as they both have a Name property (I'm doing a comparison on the Name property to use in sorting). How should I do this?
My first thought was just to overload the method with the two types as arguments:
int Compare(Type1 first, Type1 second)
int Compare (Type2 first, Type2 second)
but the body of the methods ended up being identical thus it seems like a waste.
My next thought was to use generics but that doesn't seem right because I'm not really making it generic as it can only be used with 2 specific types.
Clarification: The "custom" types are actually not my custom types. What I meant was taht they are not built-in types. I do not have control over what is in these types or the inheritence hierarchy. They just both happen to have the Name property.