What is the difference, if any, in creating a member inside a constructor, or outside of it?
Example 1:
public class Person
{
List<Person> friends = new List<Person>();
public Person()
{
}
}
Example 2:
public class Person
{
List<Person> friends;
public Person()
{
friends = new List<Person>();
}
}
I've used C# as an example, but this applies to any oop language.
Is there a practical difference between the two? I've had Example 2 being described to me as a cleaner way of implementing it for some reason.