What are the most useful (custom) code snippets for C#? [closed]
Asked Answered
K

8

8

What are the best code snippets for C#? (using visual studio) VB has a lot that are pre-defined, but there are only a handful for C#. Do you have any really useful ones for C#?

Anyone want to post a good custom one you created yourself?

Anyone?... Bueller?

Kalindi answered 6/9, 2008 at 23:59 Comment(3)
You're really going to have to be more specific... Are you looking for websites that contain web snippets and tutorials? Code snippets themselves on a particular topic? This is a very, very general question.Atchley
Have you even used any code snippets? There is no "best" code snippets. There are snippets that are more "useful" than others, but no "best" snippets. I wish i can edit the title...Elflock
Snippets work well for situation and save typing. For example I have created custom snippets because I am replacing some old code in files, and I can't use copy replace, so I can highlight the old code, and then use my snippet.Tracheostomy
C
3

Microsoft have released a whole bunch of C# snippets that bring it up to parity with the ones for Visual Basic. You can download them here:

http://msdn.microsoft.com/en-us/library/z41h7fat.aspx

Chios answered 3/7, 2009 at 14:21 Comment(1)
cool, thanks. I didn't see these...Kalindi
T
8

My absolute favorite is cw.

Tinworks answered 27/6, 2009 at 17:15 Comment(0)
M
5

There's plenty of code snippets within Visual Studio for basic programming structure but I wouldn't necessarily rate one higher than another.

I would definitely say the best ones are the custom snippets you define yourself to accomplish more specific tasks that you may find yourself using on a regular basis. Definitely a big time saver.

A fairly basic intro to creating custom snippets can be found at http://www.15seconds.com/issue/080724.htm to help with this.

Mcabee answered 7/9, 2008 at 0:23 Comment(0)
C
3

Microsoft have released a whole bunch of C# snippets that bring it up to parity with the ones for Visual Basic. You can download them here:

http://msdn.microsoft.com/en-us/library/z41h7fat.aspx

Chios answered 3/7, 2009 at 14:21 Comment(1)
cool, thanks. I didn't see these...Kalindi
T
2

These are the ones I use daily.

  • prop
  • try
  • if
  • else
  • for
  • foreach
  • mbox - Message box stub
  • The ability to role your own. I have one for Property that are saved in the view state, methods a custom class example.
Tracheostomy answered 7/9, 2008 at 2:42 Comment(0)
V
2

I had a few on my old blog:

I also have an argnull code snippet that inserts a Guard Clause that checks an argument for null and throws an ArgumentNullException, but I haven't gotten around to post that yet.

Vespertilionine answered 27/6, 2009 at 17:36 Comment(0)
F
1

prop and exception are my favorites.

Festschrift answered 7/9, 2008 at 0:21 Comment(0)
L
1

I just started a blog, where I document short solutions in C# (code snippets) that I came up with and might prove useful to other coders.

http://thorstenlorenz.blogspot.com/

So far I have mostly blogged about extension methods and generics.

So have a look and tell me what you think.

Licensee answered 27/6, 2009 at 16:40 Comment(0)
M
1

Just to update an older thread... here's a link for Visual Studio 2008 C# code snippet download.

VS 2008 C# Code Snippet Download

Mclaurin answered 25/3, 2010 at 17:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.