【发布时间】:2010-07-15 18:54:38
【问题描述】:
我想在 C# 中创建一个键值对集合,其中键是 ASP.net 控件的属性(例如 ID),值是该属性的值。我想这样做,以便以后可以遍历集合并查看给定控件是否具有我的集合中的属性(并且控件中的属性值与我的集合中定义的值匹配)。关于执行此操作的最佳方法的任何建议?感谢您的帮助。
伪代码示例:
Properties[] = new Properties[] {new Property(){name="ID",value="TestControl1"}, new Property(){name = "Text",value="Type text here"}}
private bool controlContainsProperties(Control control){
foreach(Property Property in Properties[])
{
if((control does not contain property) || (control property value != Property.Value))
return false;
}
return true;
}
【问题讨论】: