I think you should rethink this structure.
The concept of an interface is that it enables 1 or many objects to be
treated in exactly the same way, however, the requirement of different
parameters means that it cannot treat these method calls in the same way, so
combining these method calls in an interface is pointless.
You could implement:
LoadRecord(obje ct[] args);
Although I wouldn't recommend such a lack of type-safe arguments as a
consumer could pass 1 argument instead of two causing an IndexOutOfRange
exception.
You could implement
LoadRecord(stri ng productCode);
LoadRecord(stri ng orderNumber, string productCode);
// Impl 1
LoadRecord(stri ng productCode)
{
// do stuff
}
LoadRecord(stri ng productCode, string orderNumber)
{
LoadRecord(prod uctCode); // ignore order number
}
Impl 2
// Impl 1
LoadRecord(stri ng productCode)
{
throw new NotSupportedExc eption();
}
LoadRecord(stri ng productCode, string orderNumber)
{
// do stuff
}
But sooner or later Impl2 will be called with only 1 string firing the
NotSupportedExc eption.
I'd recommend you modify this idea to some else, maybe:
LoadRecord(ILoa dRecordInfo info)
Creating a new object that provides information about a request for loading
information, this can have an order number and product number etc.
HTH
"ABC" wrote:
Can I create an Interface which have a method have variate type parameters?
I want create an Interface named IDataEditable which have two methods:
LoadRecord and SaveRecord.
As the LoadRecord have variate type parameters based on the record primary
key definition such as:
The product table should be:
LoadRecord(stri ng productCode)
The OrderDetail table should be:
LoadRecord(stri ng OrderNo, string ProductCode)
Should I write the code as follow?
interface IDataEditable
{
void LoadRecord();
void SaveRecord();
}