using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Test
{
class Program
{
static void Main(string[] args)
{
List<object> list = new List<object>();
List<Dictionary<string, object>> dict = new List<Dictionary<string, object>>();
Dictionary<string, object> master = new Dictionary<string, object>();
master.Add("list", list);
master.Add("dict", dict);
List<object> mydict = (List<object>)master["dict"]; // this is where i get exception
Console.Write("Count: ", mydict.Count);
}
}
}
它在粗体线上抛出异常。为什么会出现这种行为,我该如何访问这个元素?谢谢苏曼思