我有一个IList
并且QuickWatch
可以看到以下内容
Name Value Type
ListStatusProposta { Value = "1", Text = "Beginner" } <Anonymous Type>
Text "Beginner" object{string}
Value "1" object{string}
我怎样才能foreach
访问这些属性?
更新
这就是我如何填满我的IList
protected static object[,] StatusProposta()
{
object[,] status = {
{ "1", "Beginner" },
{ "2", "Intermediate" },
{ "3", "Advanced" }
};
return status;
}
//public static IList fillLista(string nome)
public static IList<object> fillLista(string nome)
{
//List<dynamic> list = new List<dynamic>();
List<object> list = new List<object>();
object[,] objeto;
switch (nome)
{
case "StatusProposta":
objeto = StatusProposta();
break;
default:
objeto = null;
break;
}
if (objeto != null)
{
for (int i = 0; i < (objeto.Length / 2); i++)
list.Add(new { Value = objeto[i, 0], Text = objeto[i, 1] });
}
return list;
}
//IList ListaStatusProposta = fillLista("StatusProposta");
IList<object> ListaStatusProposta = fillLista("StatusProposta");
foreach()
{
// ????
}