c# 3.0 - what is use of creating property in separate class for each entilty? -


i learning code practice that's why going through code, thing not understand in it. has made property in separate class each entity in userclass has property

  #region public properties      private int uid;     public int userid     {         { return uid; }         set { uid = value; }     }      private string uname;     public string username     {         { return uname; }         set { uname = value; }     }      private string pwd;     public string password     {         { return pwd; }     //    set { pwd = value; }     }       private string uaddress;     public string useraddress     {          { return uaddress; }         set { uaddress = value; }     }       private string fname;     public string firstname     {         { return fname; }         set { fname = value; }     }      private string lname;     public string lastname     {         { return lname; }         set { lname = value; }     }      private string uphone;     public string userphone     {         { return uphone; }         set { uphone = value; }     }      private string umobile;     public string usermobile     {         { return umobile; }         set { umobile = value; }     }      private int secretquestion;     public int securityquestion     {         { return secretquestion; }         set { secretquestion = value; }     }      private string useranswer;     public string answer     {         { return useranswer; }         set { useranswer = value; }     }      #endregion 

and business logic class uses property instead of using directly entity's attribute name, confuse whats there need make property this?

other has got enums database column name has clear reason behind if in near future have change database table's fields name don't have change through out whole business logic class , can make changes enum directly, there use of creating property please elaborate me on this

are asking why uses properties instead of having public fields?

fields implementation detail - they're how data stored, shouldn't outside world cares about, @ least 99% of types. properties part of contract type has in terms of api - implementation type. in other words, it's matter of encapsulation. properties can expressed in interfaces, abstract methods etc, precisely because keep contract , implementation separate.

additionally, properties make databinding, debugging , various other things simpler. have article why properties matter, may find useful.

having said of this, properties implemented in tedious way - , don't obey .net naming conventions. have written them as:

public int userid { get; set; } public string username { get; set; } public string password { get; set; } // etc 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -