简体   繁体   中英

Namespace prefix in C#

I can already do:

using System.Windows.Forms;
Button b;

or:

System.Windows.Forms.Button b;

but I would like to do:

using System.Windows;
Forms.Button b;

(because Button is ambiguous with another namespace, and typing System.Windows.Forms.Button is too long).

However this gives me an error, how can I achieve this?

Thanks

A namespace alias perhaps:

using Forms = System.Windows.Forms;

The "using System.Windows" is now superfluous unless you use classes in that namespace.

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