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

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -