[英]Handling common classes in multiple projects in a single solution
I currently have two projects say project A and project B in my solution. 我目前在解决方案中有两个项目,分别是项目A和项目B。 Now both projects A and B are using similar classes and a copy of each class is found in each project. 现在,项目A和B都使用类似的类,每个项目中都会找到每个类的副本。 I wanted to know if there is a better way to accomplish this task. 我想知道是否有更好的方法来完成此任务。 I want to have a single class somewhere and have both projects access common classes from there. 我希望在某个地方有一个单独的类,并让两个项目从那里访问公共类。 What is the recommneded way to do this. 建议这样做的方法是什么。
using
namespace to use the class in the project A and B. 不要忘记添加正确的using
命名空间以使用项目A和B中的类。 Or just let your shared classes in project A, or B and add reference to this project in the other project (It depends on the content but doing this way will create a kind of assymetry between the projects A and B). 或者只是让您的共享类在项目A或B中,并在另一个项目中添加对该项目的引用(这取决于内容,但是这样做会在项目A和B之间产生某种不对称性)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.