i try to compare two class comp1,comp2 i used method below: ComparerCollection(array_X, array_Y); but there are errors below. Arraylist generated from Ilist. how can i do that?
namespace GenericCollecitonComparer
{
class Program
{
static void Main(string[] args)
{
myClass comp1 = new myClass() { ID = 1, Name = "yusuf" };
myClass comp2 = new myClass() { ID = 1, Name = "yusufk" };
Comparer com = new Comparer(comp1, comp2);
Console.ReadKey();
}
}
public class Comparer
{
public Comparer(myClass x, myClass y)
{
PropertyInfo[] propInfo_X = x.GetType().GetProperties();
PropertyInfo[] propInfo_Y = y.GetType().GetProperties();
ArrayList array_X = new ArrayList();
ArrayList array_Y = new ArrayList();
foreach (PropertyInfo pi in propInfo_X)
array_X.Add(pi.GetValue(x, null));
foreach (PropertyInfo pi in propInfo_Y)
array_Y.Add(pi.GetValue(y, null));
// ComparerCollection(array_X, array_Y); --> Error below
}
public bool ComparerCollection<T>(IList<T> xlist, IList<T> ylist)
{
return xlist.SequenceEqual(ylist);
}
}
public class myClass
{
public int ID { get; set; }
public string Name { get; set; }
}
}
/* Error 1 The type arguments for method '
* GenericCollecitonComparer.Comparer.ComparerCollection<T>(System.Collections.Generic.IList<T>, System.Collections.Generic.IList<T>)'
* cannot be inferred from the usage. Try specifying the type arguments explicitly.
*
*/