I have the following code in C#:
static void Main(string[] args)
{
Object rect = new Rectangle();
Object circle = new Circle();
Console.WriteLine(count(rect, circle));
}
public static int count(Object obj1, Object obj2)
{
return 4;
}
public static int count(Rectangle rect, Circle circ)
{
return 0;
}
The program outputs 4, however, I'd like it to pick the method that is more specific to this case, which would be the second method. I can't simply define the variables rect and circle as their specific types, because in the context of my code, I don't know what their types are.
Is there something entirely wrong about the way I am trying to implement this, or is there a fairly simple way to automatically choose the correct method?