, , , , , , , , Type.GetElementType() , . :
object list1 = new int[5];
object list2 = Array.CreateInstance(elementType: typeof(int),
lengths: new[] { 0 },
lowerBounds: new[] { 1 });
var type1 = list1.GetType();
var type2 = list2.GetType();
Debug.WriteLine("type1: " + type1.FullName);
Debug.WriteLine($"type1: IsArray={type1.IsArray}; ElementType={type1.GetElementType().FullName}; Is Int32[]: {type1 == typeof(Int32[])}");
Debug.WriteLine("type2: " + type2.FullName);
Debug.WriteLine($"type2: IsArray={type2.IsArray}; ElementType={type2.GetElementType().FullName}; Is Int32[]: {type2 == typeof(Int32[])}");
List<Int32> outputList = new List<int>();
outputList.AddRange(list1 as int[]);
if (type2.IsArray && type2.GetElementType() == typeof(Int32))
{
Array arrayTemp = list2 as Array;
Int32[] typedList = arrayTemp.Cast<Int32>().ToArray();
outputList.AddRange(typedList);
}
:
type1: System.Int32[]
type1: IsArray=True; ElementType=System.Int32; Is Int32[]: True
type2: System.Int32[*]
type2: IsArray=True; ElementType=System.Int32; Is Int32[]: False