C# using alias as type parameter in other using alias

前端 未结 5 1208
既然无缘
既然无缘 2021-01-13 01:33

I\'m trying to define a pair of type aliases at the top of my C# program. This is a short example of what I\'m trying to do:

using System;
using System.Colle         


        
5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-13 02:20

    Just as an addition to the other answers.

    If you really want to continue your way, nesting the namespaces would be the way to go. Since for the second namespace, the first using would then be defined.

    The following would work since you are in a deeper namespace:

    namespace N1
    {
        using TsvEntry = Dictionary;
    
        namespace N1.N2
        {
            using Tsv = List;
    
        }
    }
    

    Please note that although it is working, i wouldn't recommend using this kind of code structure since you can end up with a deeply nested code.

提交回复
热议问题