Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Type aliasing in using declarations

0.00/5 (No votes)
2 Oct 2011CPOL 7.4K  
Whilst this is a good tip, I wouldn't go as far as qualifing an entire class as you have done. I would stop at the namespace level, so your example becomes:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Drawing;using Media =...
Whilst this is a good tip, I wouldn't go as far as qualifing an entire class as you have done. I would stop at the namespace level, so your example becomes:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using Media = System.Windows.Media;
 
namespace WindowsFormsApplication1
{
    class With
    {
        public void Foo()
        {
            Color winformsColor = Color.AntiqueWhite;
            Media.Colour wpfColor = new Media.Colour();
 
            Console.WriteLine(winformsColor.ToString() + wpfColor.ToString());
        }
    }
}


I think this is more readable and less likely to confuse others who may go looking for a class definition that doesn't exist.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)