【发布时间】:2012-03-07 06:10:55
【问题描述】:
我想用这样的东西:
Dictionary<int, string>[] matrix = new Dictionary<int, string>[2];
但是,当我这样做时:
matrix[0].Add(0, "first str");
它抛出“'TargetInvocationException'...异常已被调用的目标抛出。”
有什么问题?我是否正确使用了该字典数组?
【问题讨论】:
-
嗯,你应该得到一个
NullReferenceException。显示更多代码。 -
您是否将
matrix[0]初始化为新的Dictionary<int, string>?此外,TargetInvocationException是System.Reflection命名空间的一部分。你在哪里使用反射?
标签: c# arrays dictionary