Slightly OT: Visual Studio formatting of get/set methods

D

Dylan Parry

Hi,

I'm having a minor problem getting Visual Studio (2008) to format
get/set methods how I'd like them to appear. What I currently have is:

public int ID
{
get
{
return _id;
}
set
{
_id = value;
}
}

Which is a bit too "spaced out". I'd like it to appear as:

public int ID
{
get { return _id; }
set { _id = value; }
}

Basically so it's a little more readable when it comes to me editing the
code later on.

The problem is that I've managed to set up VS2008 so that it lays out
blocks of code as in the first example by default and will automatically
reformat any blocks to look like that. I'm happy with that when it comes
to the format of classes/(most) methods etc, but when it comes to
something simple like get/set methods I'd rather they were left on one
line as initially defined.

Any ideas as to how I can change this behaviour? I've looked through the
settings several times, but I'm not sure which one to change :)

Thanks,

--
Dylan Parry
http://electricfreedom.org | http://webpageworkshop.co.uk

The opinions stated above are not necessarily representative of
those of my cats. All opinions expressed are entirely your own.
 
D

Dylan Parry

Dylan said:
Any ideas as to how I can change this behaviour? I've looked through the
settings several times, but I'm not sure which one to change :)

Sod's Law. The second I post this, I find the answer sitting right in
front of me! The solution is ofc to check "Leave block on single line"
in the "wrapping" options.

Now you can let me know why this is a bad idea ;)

--
Dylan Parry
http://electricfreedom.org | http://webpageworkshop.co.uk

The opinions stated above are not necessarily representative of
those of my cats. All opinions expressed are entirely your own.
 

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