generate getters setters

Last post 12-06-2005 5:03 PM by sewart. 2 replies.

Sort Posts:

  • Huh? [:^)] generate getters setters

    11-30-2005, 11:03 AM
    • Member
      65 point Member
    • Davycrocket
    • Member since 11-17-2005, 8:47 PM
    • Posts 13
    Hi,

    Is there a fonctionality in Visual Studio 2005 that automatically generates getters and setters for ma private class members in C#?

    thanks
  • Re: generate getters setters

    11-30-2005, 4:20 PM
    • Contributor
      6,537 point Contributor
    • bitmask
    • Member since 07-29-2003, 3:18 PM
    • Citizen of the Earth
    • Posts 1,228
    • TrustedFriends-MVPs
    You can use a code snippet to insert both the field declaration and the property get / set to encapsulate the field. The easiest way to do this is type 'prop' (without the quotes), and then hit the TAB key twice.

    If you already have a field and just need to add the get / set, right click on the field and select Refactor -> encapsulate field.
    Scott
    http://www.OdeToCode.com/blogs/scott/
  • Re: generate getters setters

    12-06-2005, 5:03 PM
    • Member
      112 point Member
    • sewart
    • Member since 08-23-2005, 7:40 PM
    • San Diego, CA
    • Posts 26

    You probably want properties instead of 'getters and setters'. There are 2 was to 'automatically' create a property.  One is to use the refractor tool.  Right click on the private variable and select Encapsulate variable and the other method is to use the class diagram GUI.

     

     

     

Page 1 of 1 (3 items)