views:

240

answers:

3

Code snippets are a pretty underused feature in Visaul Studio and it can really save you alot of time. What custom code snippets do you guys use in your everyday coding?

Let me list some of mine:

vprop - view state property

ane - argument null exception

event - definition for an event handler

noe - expands into String.IsNullOrEmpty()

What do you guys use?

A: 

till yet not any one

Kashif
-1 not helpful to say you haven't used any.
Robert MacLean
Sheesh, easy on the noobs :P
Mostlyharmless
A: 

Once I use often
propdp - Creating dependancy properties (I do lots of workflow)
tryf - Nothing like a good try finally block
foreach - create a stub foreach block. I have the devexpress stuff in so once done, it's quick to change the var to an explict item
for - for loops
exception - for creating custom exceptions

Robert MacLean
+1  A: 

I use a lot these two code snippets:

valargnull, which generates this code:

if($argument$ == null)
    throw new ArgumentNullExcption("$argument$");

and valstrempty:

if(String.IsNullOrEmpty($argument$))
    throw new ArgumentException("The value of $argument$ cannot be null or empty.", "$argument$");

where $argument$ is the text portion of the snippet you can edit.

Gerardo Contijoch