I am trying to pass separate typed dataset data tables to the same method. The datatables are similar, but distinct. The method performs the same function on the datatables. Instead of essentially duplicating the method and changing the parameter type depending on the datatable type, is there a way to do something along the lines of creating a custom interface for the datatables, that way I can have a single method with a parameter of the interface type?
what I currently have:
private PassdownDataset.SalesOrdersForManagerDataTable datatable1;
private PassdownDataset.SalesOrdersDataTable datatable2;
public SomePublicMethod()
{
PopulateDepartmentName(datatable1);
PopulateDepartmentName(datatable2);
}
private void PopulateDepartmentName(PassdownDataset.SalesOrdersForManagerDataTable dt)
{
//(operations performed on datatable)
}
private void PopulateDepartmentName(PassdownDataset.SalesOrdersDataTable dt)
{
//(operations performed on datatable)
}
what I would like to have:
private PassdownDataset.SalesOrdersForManagerDataTable datatable1;
private PassdownDataset.SalesOrdersDataTable datatable2;
public SomePublicMethod()
{
PopulateDepartmentName(datatable1);
PopulateDepartmentName(datatable2);
}
private void PopulateDepartmentName(
PassdownDataset.CommonInterfaceForBothDataTables dt)
{
//(operations performed on datatable)
}
DataTable
orIEnumerable<DataRow>
as input instead of your strongly typed DataTables or do you really need the typed DataTable functionality? - Tim Schmelter