开发者

Typesafe keyvaluepair enum

开发者 https://www.devze.com 2023-01-25 15:34 出处:网络
I have a public property on a custom control exposed like this: public IList<KeyValuePair<ControlTypes, int>> ControlCollection {get;set;}

I have a public property on a custom control exposed like this:

public IList<KeyValuePair<ControlTypes, int>> ControlCollection {get;set;}

With ControlType as type enum like this:

public enum ControlTypes : int
{
DropDownList = 1,
TextBox = 2,
}
public ControlTypes ControlType {get;set;}

Basically I am trying to create a simple user control that will add a specified number of html controls based on the input of the ControlCollection property. Like this.

<x:CustomControl ID="abc" runat="server" ControlCollection="DropDownList,1,TextBox,5"/>

How would I ensure that the ControlCollection value开发者_如何学编程 is entered in a typesafe manner? Or is this even possible? Thanks.


I think you're looking for a Dictionary<TKey, TValue>

0

精彩评论

暂无评论...
验证码 换一张
取 消