我想要实现的是下面这样的东西,Visual Studio 提示它,我不知道如何实现它:

public abstract class My_BaseControl<T> : T, IRightBasedUsability
        where T : System.Web.UI.WebControls.WebControl
{

    // Some methods that I want to have for all
    //the extended asp.net controls along my application
    //which implements IRightBasedUsability

}

最佳答案

在这种情况下,也许 c# 扩展方法是解决您问题的一种方法。

@见http://msdn.microsoft.com/en-us/library/bb383977.aspx

Eric De Carufel 写了一些关于扩展方法以及如何管理它们的范围的有趣文章:
http://blog.decarufel.net/2009/02/extension-methods-series-managing-scope.html

关于c# - 我可以从泛型类型 T 继承泛型类吗?像 MyClass<T> : T,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5802330/

10-16 04:42