简体   繁体   中英

How to make a type available in all namespaces?

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

using Excel=Microsoft.Office.Interop.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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM