There are two namespaces with class Image. One is iTextSharp
and another WPF System.Windows.Control.Image
.
Now I've to use complete reference i.e. System.Windows.Control.Image a = new ..
and iTextSharp.text.Image b = new ...
Is there any way to Aliasing the namespace, so I don't have to write complete namespace.
C# namespace aliasing The using keyword can be used to create an alias for a namespace. With nested namespaces, the fully qualified names might get long. We can shorten them by creating aliases. In the example, we create an alias for a Book class that is enclosed by two namespaces.
Namespaces in C# serve two main purposes: to organize classes and functionality and to control the scope of classes and methods. Type aliasing is a little known feature for C# and it comes in handy when you would like to alias a specific method or class from a namespace for the sake of clarity.
Namespaces are used to organize the classes. It helps to control the scope of methods and classes in larger . Net programming projects. In simpler words you can say that it provides a way to keep one set of names(like class names) different from other sets of names.
Yeps, just use:
using Img = System.Windows.Control.Image;
In your namespace declaration.
Then you can use the Img
aliased name as you used the fully qualified name previously.
Try:
using yourAlias = System.Windows.Control.Image;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With