C# using alias as type parameter in other using alias

前端 未结 5 1240
既然无缘
既然无缘 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:22

    As others have mentioned, using Alias this way is not possible, however, you can get a similar functionality using class inheritance.

    Using your example, you could do something like this:

    using System;
    using System.Collections.Generic;
    
    namespace Foo {
        class TsvEntry : Dictionary {}
        class Tsv : List {}
    }
    

    This has the additional advantage that you can easily add extra functionality to these classes later on as you need it.

提交回复
热议问题