Answers for "c# fill values of child from parent"

C#
0

c# fill values of child from parent

class Parent
{
  ...
}

class Child :Parent
{
  ...
  public Child(Parent p)
  {
            foreach (FieldInfo prop in  p.GetType().GetFields())
                GetType().GetField(prop.Name).SetValue(this, prop.GetValue( p));

            foreach (PropertyInfo prop in  p.GetType().GetProperties())
                GetType().GetProperty(prop.Name).SetValue(this, prop.GetValue( p, null), null);
  }
}
Posted by: Guest on October-22-2021

Code answers related to "c# fill values of child from parent"

C# Answers by Framework

Browse Popular Code Answers by Language