项目参考与文件参考? [英] Project Reference Vs File Reference?

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

问题描述

可以在项目中以两种方式添加引用.

References can be added in two ways in a project.

  1. 项目参考.
  2. 文件参考.

但是,什么时候使用Project和什么时候使用文件引用?

But, When to use Project and when to use File reference?

推荐答案

您没有指定,但我猜您是在指Visual Studio?

You didn't specify but I'm guessing you're referring to Visual Studio?

项目引用和文件引用之间的主要区别是实时更新是否可用.在项目参考中,您将可以通过Intellisense之类的项目立即在另一个项目中查看一个项目中的编辑效果.因此,例如,如果添加名为Foo的类,则此类型将在所有对该项目具有项目引用的项目中立即显示在intellisense中.

The main difference between a project reference and a file reference is whether or not live updates are available. In a project reference you will be able to see the effects of edits in one project immediately in the other project via items like Intellisense. So if you for instance add class named Foo, this this type will show up in intellisense immediately in any project which has a project reference on that project.

文件引用只能看到磁盘上存在的更改.必须执行编译并将位写入磁盘才能查看更改.

File references on the other hand can only see changes that are present on disk. A compilation must be performed and bits written to disk in order to see the changes.

通常,最好使用项目参考.

In general, it's best to use a project reference.

需要考虑的另一个角度是项目的相对语言.如果两个项目中的语言相同,则Project to Project引用将非常有用.如果语言不同,则倾向于将它们更像文件引用而不是项目引用.

Another angle that needs to be considered is the relative languages of the projects. Project to Project references are maximally useful if the language in both projects are the same. If the languages are different they tend to be treated more like file references than project references.

这篇关于项目参考与文件参考?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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