开发者

Using alias with 'using'

I would like to define my own alias for complex type. I'm curious why the compiler does not recognize already imported types. For example:

Works:

using System;
using System.Collections.Generic;

using myCollection = System.Collections.Generic.L开发者_C百科ist
                    <System.Collections.Generic.Dictionary<string, string>>;

Error:

using System;
using System.Collections.Generic;

using myCollection = List<Dictionary<string, string>>;


Try this:

using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{
    using myCollection = List<Dictionary<string, string>>;
}

using directives can't refer to types imported in the same scope. The above example works, because the last using directive refers only to types imported in an outer scope.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜