C# generics usercontrol

后端 未结 7 1109
梦如初夏
梦如初夏 2020-12-03 05:10

I would like to define the following control:

public partial class ObjectSelectorControl : UserControl where T : class 

The proble

7条回答
  •  心在旅途
    2020-12-03 05:18

    I don't know at which point (with which C#/.NET/VS verison update), but now it is possible to create generic control the same way you create any other generic class.

    If you create your UserControl in VS the standard way (i.e. by adding it through GUI), you simply add in both parts of class declaration ("base" class code and the designer managed file). Actually, that is what you have in your quoted code.

提交回复
热议问题