如何使所有命名空间提供一个类型? [英] How to make a type available in all namespaces?

查看:113
本文介绍了如何使所有命名空间提供一个类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我提供Excel对象在通常的方式类:

I've made Excel objects available for a class in the usual way:

使用Excel =的Microsoft.Office.Interop.Excel;

不过,我会制定了许多类在这个项目中,其中大部分将需要与Excel对象的工作,而且好像我必须把这个在每个文件的头。有没有办法,我以某种方式在项目层面进入这个使用语句,所以我没有将它添加在每一个文件,并使其更容易改变如果由于某种原因,我决定开始使用一个不同的Excel库?

However, I'll be developing many classes in this project, most of which will need to work with Excel objects, and it seems like I'd have to put this in the header of every file. Is there a way for me to somehow enter this using statement at the project level, so that I don't have to add it in every file, and make it easier to change if for some reason I decide to start using a different Excel library?

推荐答案

没有,有没有这样的东西作为一个项目范围在C#中使用指令。你需要在想利用它的每个文件中的指令。

No, there's no such thing as a project-wide using directive in C#. You'll need a directive in each file that wants to take advantage of it.

这篇关于如何使所有命名空间提供一个类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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