Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Namespace prefix in C#

Tags:

namespaces

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

like image 445
Laurent Avatar asked May 14 '09 09:05

Laurent


1 Answers

A namespace alias perhaps:

using Forms = System.Windows.Forms;

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

like image 54
Peter Lillevold Avatar answered Sep 30 '22 21:09

Peter Lillevold