These are the 2 sets of activities :
//#1
List<object> AFilterObject = A_List.SelectedList;
List<A> AFilters = new List<A>();
foreach (Aitem in AFilterObject )
{
//Do activity X
}
//#2
List<object> BFilterObj = B_List.SelectedList;
List<B> payopFilters = new List<B>();
foreach (B item in BFilterObj )
{
//Do same activity X }
As you can see both the set of activities are common except for the type involved. How can I write a method with 2 parameters - filterObject, Type - so that I can use this method in a common manner?
To make myself clearer, the final objective is:
CommonMethod(List<object> x, Type y???) { //cast x to type y then do some stuff }
//so that I can call
CommonMethod(BFilterObj ,B);
//or
CommonMethod(AFilterObj ,A);