c# - Is there a more efficient way to define similar public properties -


i've got class 20 public properties. these properties have in common strings , filled data different tables of database.

additionally set pretty normal while special need call specific method. done each property @ moment (see below).

my question here is: there more efficient way of doing this, way don't have define each public property hand in way?

class myclass {      private string _firstname;      private string _lastname;      .....      public string firstname      {          {              return modifystringmethod(this._firstname);          }           set {              this._firstname = value;          }      } } 

like mentioned above every public property looks same. calls modifystringmethod private member given parameter while set sets private member.

you try automatic code generation using t4 template. perfect when have simple, repeating pattern of code , not expecting cases different others.

simply define xml list of property names , have t4 template generate partial class each property.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -