Uses of using
Patrick Lavoie
anti-bug informatique
December 1st 2004
Copyright © 2004
Did you know what the anti-bug informatique
December 1st 2004
Copyright © 2004
using keyword could be used for?IDisposable interface when they go out of the using block.alias would have been unintuitive!If we think about it, the second and third usages are in fact both aliases. The difference with the second case is that you simply don't give any name to the namespace. You just create an unnamed alias.
So if you don't like the class name
Object and you would prefer to call it (let's be imaginative and create an alias that no one could have ever thought of) object (without the capital "O"), we could do something like:
using object = System.Object;
Then, whenever we want to use the
Object class, we can either call it System.Object, Object or object.