Advertisement
Guest User

Untitled

a guest
Sep 27th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. public class Main
  2. {
  3. public List<B> BList{ get; set; }
  4. }
  5. public class B
  6. {
  7. public B()
  8. {
  9. ListA = new List<A>();
  10. }
  11. public string FirstName { get; set; }
  12. public string LastName { get; set; }
  13. public string Email { get; set; }
  14. public List<A> ListA { get; set; }
  15. }
  16. public class A
  17. {
  18. public int Rating { get; set; }
  19. public int Weightage { get; set; }
  20. }
  21.  
  22. Main main = new Main ();
  23. var xEle = new XElement("Root", from x in main.BList
  24. from te in x.A select new XElement("Child", new XElement("Weightage", te.Weightage), new XElement("FName", x.FirstName),new XElement("LName", x.Email) ));
  25.  
  26. <Root>
  27. <Child>
  28. <Weightage>10</Weightage>
  29. <FName>ABC</FName>
  30. <LName>ABC@gmail.com</LName>
  31. </Child>
  32. <Child>
  33. <Weightage>20</Weightage>
  34. <FName>ABC</FName>
  35. <LName>ABC@gmail.com</LName>
  36. </Child>
  37. </Root>
  38.  
  39. <Root>
  40. <Child>
  41. <Weightage>10</Weightage>
  42. <Weightage>20</Weightage>
  43. <FName>ABC</FName>
  44. <LName>ABC@gmail.com</LName>
  45. </Child>
  46. </Root>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement