我想在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;
}