在 C# 中使用被引用项目引用的类型 [英] Use types referenced by a referenced project in C#

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

问题描述

我是将应用程序拆分为多个解决方案的新手(换句话说,我刚刚进入现实世界),我有一种情况,我将逻辑与 UI 完全分离到一个单独的项目中.我摔倒的地方是我的胶水代码.

I'm new to splitting up my applications into multiple solutions (in other words I just got into the real world), I have a situation where I'm fully seperating the logic from the UI into a seperate project. Where I'm falling down is my glue code.

举个简单的例子.

Project car 引用包含门、收音机等的项目

Project car references projects containing door,radio etc

项目车库参考项目汽车,但需要使用收音机.

Project garage references project car, but needs to use radio.

我需要在车库项目中添加对收音机项目的引用吗?

Do I need to add a reference to the radio project in the garage project?

推荐答案

是的,您需要添加对这两个库的引用.通常,您需要添加对所有声明您直接使用的类型的库的引用;通过声明这些类型的变量,从它们继承,使用具有该类型作为参数或返回类型的方法等.

Yes, you'll need to add a reference to both libraries. In general, you need to add a reference to all libraries declaring types you directly use; by declaring variables of those types, inheriting from them, using methods that has the type as parameters or return type, etc.

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

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