Maybe it's a newbie question, but could anyone explain me how the tied/linked classes (I don't know their true names) are made? The example can be LINQ TO XML
.
When I have the beneath code:
XDocument doc = XDocument.Load("...");
XElement element = doc.Element("root");
element.SetAttribute("NewAttribute", "BlahBlah");
doc.Save("...");
I change only element
variable (I don't need to update it in doc
because its referenced). How to create such classes?
[edit]
I tried @animaonline's code and it works
A a = new A();
B b = a.B(0);
b.Name = "asd";
Console.WriteLine(a.Bs[0].Name); // output "asd"
But tell what's the difference with the code above and below?
List<string> list = new List<string>();
list.Add("test1");
list.Add("test2");
var test = list.FirstOrDefault();
test = "asdasda";
Console.WriteLine(list[0]); // output "test1" - why not "asdasda" if the above example works???