且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何约束泛型是枚举类型的?

更新时间:2023-02-04 13:21:40

这是在支持IL水平,但不是在C#。你可以看看不受约束的旋律通过乔恩斯基特写,让你实现这个。而这里的相应博客文章在那里,他解释细节。

This is supported at the IL level but not in C#. You may take a look at unconstrained melody written by Jon Skeet which allows you to achieve that. And here's the corresponding blog post where he explains in details.