如何确定数组的基础类型
问题描述:
可能重复:
如何获取阵列NET中的数组类型中的项目类型
Possible Duplicate:
How do I get the Array Item Type from Array Type in .net
如果我有一个特定类型的数组,有没有办法分辨出该类型到底是什么?
If I have an array of a particular type is there a way to tell what exactly that type is?
var arr = new []{ "string1", "string2" };
var t = arr.GetType();
t.IsArray //Evaluates to true
//How do I determine it's an array of strings?
t.ArrayType == typeof(string) //obviously doesn't work