Visual Studio 2005 Code Snippets
非常喜欢Visaul Studio 2005 中的代码段,大大节省了一些无聊的、没有技术含量的代码编写工作,如实体类的属性设置等。
Visual Studio 2005 中的 VB.NET 的代码段比 Visual C# 的多出不少,是不是吸引开发人员?
我们可以修改系统中现有的 snippet 文件(C:\Program Files\Microsoft Visual Studio 8\VC#\Snippets\2052\Visual C#目录),来增加自己常用的 snippet。
网上(
http://www.gotcodesnippets.net/)也有不少别人编写的 snippet ,可以按需取用。
要想共享或发布 snippet,最好做成Visual Studio 支持的格式 vsi ,其实是就是一个 更改了后缀名的 zip 文件,里面包含一个 XML 描述文件、一个或多个 snippet 文件(可以从上面网站中获得一个 vsi 文件来参考如何制作过程)。
在 Visual Studio 2005 中,插入代码段的快捷键是 Ctrl K + Ctrl X ,代码段管理器的快捷窗口是 Ctrl K + Ctrl B。
IntelliSense Code Snippets are reusable, task-oriented blocks of code. Visual Studio 2005 includes code snippets covering tasks ranging from creating a custom exception, to sending an e-mail message, to drawing a circle. A set of Visual Basic and Visual C# Code Snippets are included in the Visual Studio 2005 box – additional Code Snippets can be found below.
Visual C#Task-Based Code SnippetsThis is a set of task-based code snippets in C# that can help you with programming tasks ranging from working with databases and windows applications to writing mobile device applications and networking programs.
Note: Visual Basic versions of these snippets are included in the box.Download all the C# Code SnippetsNote: In order for Visual Studio to recognize the location of these snippets, you will need to add the installed directory to the Code Snippet Manager within Visual Studio (see
How to: Manage Code Snippets).
You can also download the Visual C# code snippets by clicking on the categories below.
| | Application Code Snippets For working with Isolated Storage, ClickOnce tasks, Console Applications and Process Management. |
| | Collections and Arrays Code Snippets For tasks like creating, iterating, locating elements, and sorting collections like arrays and dictionaries. |
| | Connectivity Code Snippets For checking network status, downloading a file via HTTP, performing serial port operations, sending email and more. |
| | Crystal Reports Code Snippets For common reporting tasks such as printing a Crystal Report, setting report parameters, and configuring report data access. |
| | Database Code Snippets For performing a variety of common tasks around ADO.NET data access. |
| | Datatypes Code Snippets For various string conversions, date spanning operations, and other type-focused operations. |
| | File System Code Snippets For performing a number of tasks around reading, writing, and managing files. |
| | Math Code Snippets For calculating monthly payments, depreciation, sines, cosines, and random numbers. |
| | Operating System Code Snippets A large collection of snippets for Event logging, Message Queues, Process management, registry access, windows services, getting system information and more. |
| | Security Code Snippets For working with hashes, decrypting, encrypting, and getting a user’s name. |
| | Smart Devices Code Snippets For performing common tasks on Smart Devices. |
| | Windows Forms Code Snippets For working with the clipboard, fonts, sounds, GDI drawing, and general Windows Form and control creation. |
| | XML Code Snippets For reading and writing XML, selecting nodes, performing XSL transforms, and other XML oriented tasks. |
| | Refactoring Code Snippets These code snippets are used to restore the default set of snippets that C# refactoring currently uses for refactoring operations in the Visual Studio IDE. These snippets are installed by default with Visual Studio and should only be used to restore your C# refactoring snippets if they become corrupt or deleted. |