我有一个返回HashTable
. 我想在不重构我的属性的情况下对其进行排序。请注意:我不想返回另一种类型。代码:
/// <summary>
/// All content containers.
/// </summary>
public Hashtable Containers
{
get
{
Hashtable tbl = new Hashtable();
foreach (Control ctrl in Form.Controls)
{
if (ctrl is PlaceHolder)
{
tbl.Add(ctrl.ID, ctrl);
}
// Also check for user controls with content placeholders.
else if (ctrl is UserControl)
{
foreach (Control ctrl2 in ctrl.Controls)
{
if (ctrl2 is PlaceHolder)
{
tbl.Add(ctrl2.ID, ctrl2);
}
}
}
}
return tbl;
}
}