casting collections heeeellpppp
i am trying to turn these 2 methods into one
private int IndexOfControl(string strName, string strControlType)
{
int iIndex = 0;
foreach(Control tmpControl in this.Controls)
{
if(tmpControl.Name == strName & tmpControl.GetType().ToString() == strControlType)
return iIndex;
iIndex++;
}
iIndex = 0;
return -1;
}
private int IndexOfColumn(string strName, string strControlType)
{
int iIndex = 0;
foreach(columnheader comunalHeader in this.listView_LanguageDirs.Columns)
{
if(comunalHeader.Name == strName & comunalHeader.GetType().ToString() == strControlType)
return iIndex;
iIndex++;
}
iIndex = 0;
return -1;
}
this is what i have so far but the casting seems not to work
i dont know how to cast properly
any ideas ?
private int IndexOfComunal(string strName, string strControlType, object collection, object iter)
{
int iIndex = 0;
CollectionBase cb;
cb = (CollectionBase) collection;
iter = (Type.GetType(iter.GetType)) iter;
foreach(iter in cb)
{
if(comunalHeader.Name == strName & comunalHeader.GetType().ToString() == strControlType)
return iIndex;
iIndex++;
}
return -1;
}
thanks

