Type-alias in C#

I just found out, you can create an alias for a type. This is especially handy for generic collection types.

using System;
using SlowArray=System.Collections.Generic.Dictionary<int,string>;
 
class Program
{
	static void Main(string[] args)
	{
		SlowArray d = new SlowArray();
		d.Add(0, "ing");
		Console.WriteLine(d[0]);
	}
}

The using alias directive was introduced in .NET Framework v1.1. However, generics were introduced in v2.0.

 
blog\type_alias_in_c.txt · Last modified: 2009-01-05T15:56
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki