So I learned something TOTALLY COOL from a coworker today! I’m always excited about learning something new when it comes to coding.
I’ve frequently been in the situation where I’ve wanted to create a Switch statement while using enums
.
So to start everything off create a generic class with an enum like this:
public class GenericClass {
public enum ManyEnums {
Foo, Bar, Huuuurk, Blah, FourtyTwo
}
public void DoSomething(ManyEnums i) {
}
}
Inside of DoSomething
type switch
and then press tab
. Something cool like this should automatically be generated:
While switch_on
is highlighted, type i
then press the down arrow. This should appear:
Blew my MIND! So much I skipped my lunch to do this blog post before I left work.
I was aware that a similar snippet existed in VB for property creation. It’s pretty awesome getting to learn something new with something you’ve been using for a really long time!
If you are aware of any other useful snippets that are built into VisualStudio, shoot them my way so I can share them!
You can also make your own snippets, and it’s really easy. :o) I love the heck out of this feature.
Here’s a decent post about how to go about doing it:
http://blogs.msdn.com/b/sburke/archive/2011/03/29/my-visual-studio-snippets.aspx
As a side-benny, you can use the snippet manager to browse all of the built-in snippets.
Wow! This can be one particular of the most beneficial blogs We have ever arrive across on this subject. Basically Fantastic. I’m also a specialist in this topic so I can understand your effort.
Great write-up, I’m regular visitor of one’s blog, maintain up the nice operate, and It’s going to be a regular visitor for a lengthy time.
More about c# enum….C# Enum
Zene