更新多个项目中使用的类? [英] Updating classes used in multiple projects?

查看:77
本文介绍了更新多个项目中使用的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些抽象的类,可以在多个项目中使用它们.我一直在研究这些类,进行优化,添加等.因此,当我在其中一个类中进行某些优化时,我需要将该新版本复制到我记得使用过的每个项目中.这不是一个很好的方法,但是有更好的方法吗?

I have a few classes that are abstracted in a way that I can use them in multiple projects. I'm always working on these classes, optimizing, adding, etc. So when I optimize something in one of these classes, I then need to copy that new version into every project I remember using it. This isn't a very good way of doing it, but is there a better way?

谢谢

推荐答案

不是将更新的类手动复制到使用它们的每个项目中,而是创建一个 Class Library 项目并引用已编译的类. .这样组织您的类将有助于您遵循DRY(不要重复自己")原则.

Instead of manually copying the updated classes to every project that uses them, create a Class Library project and reference the compiled file in every project that uses the classes. Organizing your classes like that will help you to follow the DRY ("Don't repeat yourself") principle.

但是,如果需要引用文件而不是编译的库,则可以将文件引用为链接,以便多个项目引用同一文件,而无需将其复制到每个解决方案文件夹中.为此,请右键单击您的项目,选择添加现有项... ,浏览到.cs文件,然后从下拉菜单中的添加为链接右下角.

If you need to reference files instead of compiled libraries, however, you can reference a file as a link so that multiple projects refer to the same file without copying it to each solution folder. To do that, right-click on your project, choose Add existing item..., browse to the .cs file, and choose Add as Link from the combobox in the right lower corner.

这篇关于更新多个项目中使用的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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