c# - How to merge multiple object of child class to single parent object -




i have created 4 classes inside single parent class. since child classes have individual properties need assign different values , need merge objects of child class parent class me in creation , pass single object inside method argument.

enter image description here

what have not child classes, nested classes. want neither. want this:

public class person {   public string name { get; set; }   public int age { get; set; } }  public class {   public person b { get; set; }   public person c { get; set; }   public person d { get; set; }   public person e { get; set; } }  internal static class program {   private static void method(a a)   {     console.writeline(a.e.name);   }    internal static void main()   {     var = new               {                 b = new person { name = "peter", age = 31 },                  c = new person { name = "paul", age = 78 },                  d = new person { name = "mary", age = 24 },                  e = new person { name = "jane", age = 15 }               };      method(a);   } } 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -