shorcut for properties

S

Sonnich Jensen

Hi

I recall there is a way to get the structure of get/set just as
three /// will give the summerise structure.

Just how do I get the get/set structure?

Sonnich
 
J

Jeff Johnson

I recall there is a way to get the structure of get/set just as
three /// will give the summerise structure.

Just how do I get the get/set structure?

I don't understand the question. What kind of "structure" are you looking to
"get"? Are you trying to determine if a given property has a get and/or set
defined? And perhaps its protection level? An example would be nice.
 
R

Rick Lones

Sonnich said:
Hi

I recall there is a way to get the structure of get/set just as
three /// will give the summerise structure.

Just how do I get the get/set structure?

Sonnich

In the IDE, define your backing variable in lower case as per, e.g.:
public int prop;

Then position the cursor on the variable name (or highlight it), right click and
choose Refactor/Encapsulate Field from the popup menu. This will give you a
dialog box - click OK (then "Apply" if previewing) and this will cause, e.g.:

public int Count
{
get { return prop; }
set { prop = value }
}

to be generated for you. Or at least that is the procedure in VS 2005. (I
think this is what you are asking?)

HTH,
-rick-
 
R

Rick Lones

Rick said:
In the IDE, define your backing variable in lower case as per, e.g.:
public int prop;

Then position the cursor on the variable name (or highlight it), right
click and choose Refactor/Encapsulate Field from the popup menu. This
will give you a dialog box - click OK (then "Apply" if previewing) and
this will cause, e.g.:

public int Count
{
get { return prop; }
set { prop = value }
}

to be generated for you. Or at least that is the procedure in VS 2005.
(I think this is what you are asking?)

HTH,
-rick-

Correction - should be "private int prop" for the backing variable.

-rick-
 
S

Sonnich Jensen

In the IDE, define your backing variable in lower case as per, e.g.:
public int prop;

Then position the cursor on the variable name (or highlight it), right click and
choose Refactor/Encapsulate Field from the popup menu.  This will give you a
dialog box - click OK (then "Apply" if previewing) and this will cause, e..g.:

public int Count
{
     get { return prop; }
     set { prop = value }

}

to be generated for you.  Or at least that is the procedure in VS 2005. (I
think this is what you are asking?)

HTH,
-rick-

It is, I did not know the words for this. But I know there is an
easier way, the same as typing "///". It exists in VS2008.

Sonnich
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top