11 October 2007 - 1:43 PM / by Dominic Pettifer. 1 Comment for Using Namespace Aliases.
Cool C# Snippets - Ever get tired of prefixing class names with the fully qualified namespace to avoid class name and namespace conflicts (eg. System.Namespace.AnotherNamespace.User). Well there’s a way around it using Namespace Aliases.
Ever grow tired of writing this...
System.Web.Namespace.AnotherNamespace.YetAnotherNamespace.User user = new System.Web.Namespace.AnotherNamespace.YetAnotherNamespace.User();
...all so you can use the User object in that namespace without it conflicting with about a gazillion other User classes elsewhere? If so then use a Namespace alias eg...
using MyAlias = System.Web.Namespace.AnotherNamespace.YetAnotherNamespace;
and in your code...
MyAlias.User user = new MyAlias.User();
Alternatively you can also alias the class itself eg...
using CustomUser = System.Web.Namespace.AnotherNamespace.YetAnotherNamespace.User;
and in code...
CustomUser user = new CustomUser();
Pretty cool time saving technique I reckon.
And whoa, that’s my first post on this blog in nearly 10 months! Seems I hardly get any time to write these things, so I'm going to try and write them shorter like this.
Look at this, there's life on the site. And an interesting tip as well. Thx.
Posted on 11 October 2007 - 1:29 PM / by Littlefool
@elijahmanor FYI the Accordian control in your latest Tech Tweets seems broken (9th March), ASP.NET and ASP.NET MVC entries missing
about 4 hours ago from EchofonRT: @mkristensen: Search for "recursion" on Google and see if you can spot the easter egg - Awesome!
about 17 hours ago from Echofon@shanselman Turn off hardware acceleration in Flash (right click on Flash area), or try updating your graphics card drivers
about 19 hours ago from EchofonBlogged: Dependency Injection in #aspnetmvc 2.0 – Part 3: Custom DataAnnotation ValidationAttributes http://bit.ly/adKiez
12:21 AM March 9th from EchofonMy greatest anti-achievement yet. I've managed to bring down an entire site by putting !exclamation! mark (C# NOT operator) in wrong place
9:48 AM March 8th from Echofon