c# - Can some one please explain how the two classes differ in execution? -


i testing class in linqpad , constructed basic class cannot head around how 2 classes differ in execution. can please me out?

public class name // 1 {     public string name1 {get;set;}     public surname surname = new surname(); }  public class name // 2 {     public string name1 {get;set;}     public surname surname {get;set;}     public name()     {     surname = new surname();     } } public class surname {     public string surname1 {get;set;}     public string surname2 {get;set;} } 

i rewrite classes, clr define code this

public class name // 1 {     private string _name1;     public string get_name1()     {          return _name1;     }      public void set_name1(string value)     {          this._name1=value;     }      public surname surname = new surname(); }  public class name // 2 {             private string _name1;     public string get_name1()     {          return _name1;     }      public void set_name1(string value)     {          this._name1=value;     }      private surname _surname = new surname();     public surname get_surname()     {          return _surname;     }      public void set_surname(surname value)     {          this._surname=value;     }  } 

Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -