How to access Properties of a class from a Generic Method - C#

前端 未结 5 628
-上瘾入骨i
-上瘾入骨i 2020-12-06 16:49

I have a three class which is having following properties

Class A
{
    public int CustID { get; set; }
    public string Name{ get; set; }
}

Class B
{
             


        
5条回答
  •  日久生厌
    2020-12-06 17:16

    Inheritance will work

    public abstract class ABBase
    {
        public int CustID { gete; set; }
    }
    
    public class A : ABBase
    {
        public string Name { get; set; }
    }
    
    public class B : ABBase
    {
        public string Age { get; set; }
    }
    

    Then rather than a generic method use

    public void ProcessData(IList param1, string date)
    {
        Parallel.ForEach(T, (currentItem) =>
        {
            GetDetails(CustID )
        });
    }
    

提交回复
热议问题