I have 2 overloaded C# functions like this:
private void _Insert(Hashtable hash, string tablename, Func<string, object[], SqlCommand> command)
private void _Insert(Hashtable hash, string tablename, Func<string, object[], OleCommand> command)
Basically one using OleCommand and the other SqlCommand for the return value of the function.
But the ugly thing about this is that I have to cast the function pointer to the correct type even though i feel the compiler should be able to resolve it without problems:
class RemoteDatabase
{
public SqlCommand GetCommand(string query, object[] values);
}
_Insert(enquiry, "Enquiry", (Func<string, object[], SqlCommand>)(_RemoteDatabase.GetCommand));
Is there any way tell the compiler to be smarter so that I don't have to do the type casting? Or did I do anything wrong?
EDIT: Added a bounty because I am really interested to learn. Thanks for any advice.