C#最有用(自定义)的代码片段是什么?

时间:2022-09-06 18:34:11

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#?

C#的最佳代码片段是什么? (使用visual studio)VB有很多预定义的,但C#只有少数。你对C#有什么有用的吗?

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

有人想发布你自己创建的好习惯吗?

Anyone?... Bueller?

8 个解决方案

#1


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:

微软发布了一大堆C#片段,使其与Visual Basic的片段相提并论。你可以在这里下载它们:

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

#2


5  

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

Visual Studio中有大量的代码片段用于基本的编程结构,但我不一定要比另一个更高。

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.

有关创建自定义代码段的相当基本的介绍,请访问http://www.15seconds.com/issue/080724.htm以帮助解决此问题。

#3


5  

My absolute favorite is cw.

我最喜欢的是cw。

#4


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.

我还有一个argnull代码片段,它插入一个Guard子句,用于检查null的参数并抛出ArgumentNullException,但我还没有发布它。

#5


1  

prop and exception are my favorites.

道具和例外是我的最爱。

#6


1  

These are the ones I use daily.

这些是我每天使用的。

  • prop
  • try
  • if
  • else
  • for
  • foreach
  • mbox - Message box stub
  • mbox - 消息框存根

  • The ability to role your own. I have one for Property that are saved in the view state, methods a custom class example.
  • 能够自己发挥作用。我有一个属性保存在视图状态,方法一个自定义类示例。

#7


1  

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

只是为了更新旧线程...这里是Visual Studio 2008 C#代码片段下载的链接。

VS 2008 C# Code Snippet Download

VS 2008 C#代码段下载

#8


0  

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.

我刚刚创建了一个博客,在那里我记录了我提出的C#(代码片段)中的简短解决方案,并且可能对其他编码器有用。

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.

所以看看并告诉我你的想法。

#1


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:

微软发布了一大堆C#片段,使其与Visual Basic的片段相提并论。你可以在这里下载它们:

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

#2


5  

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

Visual Studio中有大量的代码片段用于基本的编程结构,但我不一定要比另一个更高。

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.

有关创建自定义代码段的相当基本的介绍,请访问http://www.15seconds.com/issue/080724.htm以帮助解决此问题。

#3


5  

My absolute favorite is cw.

我最喜欢的是cw。

#4


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.

我还有一个argnull代码片段,它插入一个Guard子句,用于检查null的参数并抛出ArgumentNullException,但我还没有发布它。

#5


1  

prop and exception are my favorites.

道具和例外是我的最爱。

#6


1  

These are the ones I use daily.

这些是我每天使用的。

  • prop
  • try
  • if
  • else
  • for
  • foreach
  • mbox - Message box stub
  • mbox - 消息框存根

  • The ability to role your own. I have one for Property that are saved in the view state, methods a custom class example.
  • 能够自己发挥作用。我有一个属性保存在视图状态,方法一个自定义类示例。

#7


1  

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

只是为了更新旧线程...这里是Visual Studio 2008 C#代码片段下载的链接。

VS 2008 C# Code Snippet Download

VS 2008 C#代码段下载

#8


0  

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.

我刚刚创建了一个博客,在那里我记录了我提出的C#(代码片段)中的简短解决方案,并且可能对其他编码器有用。

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.

所以看看并告诉我你的想法。