Results 1 to 9 of 9
  1. #1
    Join Date
    Jul 2007
    Posts
    8

    Question Hyperion skeleton 02 template help

    About 47 mins in Logan explains that you don't have to write out all of a variable and it's property by typing prop and hitting tab twice. This is the template Logan gets by hitting tab twice followed by the template I get.

    Code:
            private int myVar;
    
            public int MyProperty
            {
                get { return myVar; }
                set { myVar = value; }
    
            }
    Code:
             public int MyProperty { get; set; }
    Did I miss something, how can I get the same template to appear?

  2. #2
    Join Date
    Jan 2007
    Posts
    216
    You didn't miss anything, prop was changed to the new automatic properties, which were introduced in C#3.0.

    If you really want the old style back extract this oldprop.zip into "%USERPROFILE%\Documents\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets" (or Visual Studio 2010 depending on your version).

    If you now type propp you get the old properties.
    Last edited by Dragonclaw1988; 03-16-2012 at 08:22 PM.

  3. #3
    Join Date
    Dec 2003
    Location
    3dbuzzmania
    Posts
    4,064
    Just get used to the new way...

  4. #4
    Join Date
    Jul 2007
    Posts
    8
    Thank you. The new way doesn't seem very practical, I might as well type out the whole variable and property.

  5. #5
    Join Date
    Apr 2010
    Location
    Alabama
    Posts
    100
    To me it doesn't seem practical to have six lines of code when a single line of code does the exact same thing, and is (imo) easier to read.

    I personally would recommend using the newer style, but use whatever is comfortable =)
    Get your facts first, and then you can distort them as much as you please. - Mark Twain

  6. #6
    Join Date
    Jul 2007
    Posts
    8
    You mean like this?
    Code:
    public int MyProperty { get return myVar; set myVar = value; }

  7. #7
    Join Date
    Sep 2008
    Location
    Salisbury, UK
    Posts
    2,812
    Code:
    public int MyProperty { get; set; }
    unless you're in need of extra functionality in the getter or setter, in which case use the backing field.

    I found
    my current avatar on google, so props to THIS GUY who created the original...

  8. #8
    Join Date
    Jul 2007
    Posts
    8
    Thank you

  9. #9
    Join Date
    Oct 2011
    Posts
    547
    If you want the old way of doing things, write propfull instead of prop.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •