Assuming we have the following model:
public class Father
{
public Child Child { get; set; }
public string Name { get; set; }
public Father() { }
}
public class Child
{
public Father Father;
public string Name { get; set; }
}
And the following implementation:
var father = new Father();
father.Name = "Brad";
var child = new Child();
child.Father = father;
child.Name = "Brian";
father.Child = child;
Now my question: Is codesnippet #1 equivalent to codesnippet #2?
Or does it take longer to run codesnippet #1?
CodeSnippet #1:
var fatherName = father.Child.Father.Child.Father.Child.Name;
CodeSnippet #2:
var fatherName = father.Name;