如何在 Visual Studio 2010 中存储可重用代码? [英] How to store reusable code in Visual Studio 2010?

查看:30
本文介绍了如何在 Visual Studio 2010 中存储可重用代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以在 Visual Studio 2010 中保存我的代码块并在我未来的 Web 应用程序中重用它,而不必添加现有文件"?VS2010 中是否有一项功能可以让您全局存储这些代码块?

Is there any way I could save my block of code in Visual Studio 2010 and reuse it in my future web applications without having to "Add existing files"? Is there a feature in VS2010 that lets you globally store these blocks of code?

谢谢!

推荐答案

Oded 几乎涵盖了它,但我只是在这里重申一下.您可以通过三种主要方式执行此操作,具体取决于您要存储的代码量.

Oded pretty much covered it but I'll just reiterate here. There are three main ways you can do this depending on how much code you want to store.

对于一些代码,只需将代码复制到您的工具箱:http://blogs.msdn.com/b/zainnab/archive/2010/01/24/drag-and-drop-code-onto-the-toolbox-vstiptool0007.aspx

For a little code just copy the code to your Toolbox: http://blogs.msdn.com/b/zainnab/archive/2010/01/24/drag-and-drop-code-onto-the-toolbox-vstiptool0007.aspx

对于很小的代码到非常大的代码块(具有一些智能输入值),您可以使用代码片段:http://blogs.msdn.com/b/zainnab/archive/tags/tips+and+tricks/snippet/

For a little code to very large blocks of code (with some intelligence for putting in values) you can use code snippets: http://blogs.msdn.com/b/zainnab/archive/tags/tips+and+tricks/snippet/

对于许多自定义文件、资源等...本质上构成一个新项目,您应该使用项目模板:http://blogs.msdn.com/b/zainnab/archive/2010/02/22/roll-your-own-project-or-item-with-the-export-template-wizard-vstipproj0004.aspx

And for lots of custom files, resources, etc... that essentially make up a new project you should use project templates: http://blogs.msdn.com/b/zainnab/archive/2010/02/22/roll-your-own-project-or-item-with-the-export-template-wizard-vstipproj0004.aspx

这篇关于如何在 Visual Studio 2010 中存储可重用代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆