assign some inner list details to another different inner list c#

Viewed 29

I have below classes.

 public class CLASS_A2
    {
    public string a2s1 {get;set;}
    public string string_a {get;set;}
    }

    public class CLASS_B2
    {
    public string a2s1 {get;set;}
    public string someotherstring_b {get;set;}
    }

    public class CLASS_A1
    {
    public string a1s1 {get;set;}
    public string a1s2 {get;set;}
    public string a1s3 {get;set;}
    public CLASS_A2[] nested_members {get;set;}
    }
 
    public class CLASS_B1
    {
    public string a1s1 {get;set;}
    public string a1s2 {get;set;}
    public string a1s3 {get;set;}
    public CLASS_B2[] nested_members {get;set;}
    }
   
    public class CLASS_A
    {
    public string a {get;set;}
    public string b {get;set;}
    public CLASS_A1[] nested_members {get;set;}
    }



    public class CLASS_B
    {
    public string a {get;set;}
    public string b {get;set;}
    public CLASS_B1[] nested_members {get;set;}
    }

as mentioned above, CLASS_A and CLASS_B are my parent classes. and for them, some inner classes are there. for both parent and thier inner classe members are almost same, except only CLASS_A2 and CLASS_B2 having string_a and someotherstring_b. For some reson, i need to map all the common details of CLASS_A has to map with CLASS_B.

Tried things: but,in this case, i can't use 'AddRange' method as below due to parameter difference.

class_b_list.AddRange(class_a_list);

also, if i try to use linq query as below. i can't access inner classes. as below.

    List<CLASS_B> class_b_map=new List<CLASS_B>();
    class_b_map=( from q in class_a_object
              from w in q.class_a1_object
              from e in w.class_a2_object
              select new CLASS_B
              {
              //here i can't access CLASS_B inner parameters to assign the data.
              }
              ).ToList();

suggest any way to get out of this!! Thanks in advance.!

0 Answers
Related