vendredi 5 octobre 2018

C# check if two classes have the same properties and return the different ones

I have two classes

public class Person
    {
        public int Id { get; set; }
        public int Name { get; set; }
        public DateTime DOB { get; set; }
        public string Address { get; set; }
    }

public class AnotherPerson
{
    public int Id { get; set; }
    public int Name { get; set; }
    public DateTime DOB { get; set; }
    public string Address { get; set; }

    public string Email { get; set; }

}

I need to know if two classes have the same properties and if not I want to dynamically add the other properties to the missing one to make both classes the same.

I tried to use Reflection but I got stuck in it.

Thanks.





Aucun commentaire:

Enregistrer un commentaire