Why can one aliased C# Type not be accessed by another?

Posted by jdk on Stack Overflow See other posts from Stack Overflow or by jdk
Published on 2010-03-12T01:05:05Z Indexed on 2010/03/12 1:17 UTC
Read the original article Hit count: 300

Filed under:
|
|

good stuff

// ok to alias a List Type
using AliasStringList = System.Collections.Generic.List<string>;

// and ok to alias a List of Lists like this
using AliasListOfStringList1 = System.Collections.Generic.List<System.Collections.Generic.List<string>>;

bad stuff

// However **error** to alias another alias
using AliasListOfStringList2 = System.Collections.Generic.List<AliasStringList>;

Produces the compile error

The type or namespace name 'AliasStringList' could not be found (are you missing a using directive or an assembly reference?)

Note: this is the using directive not the using statement.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET