This is another sample,
using System;
using System.Collections.Generic;
public static class Program
{
public static void Main()
{
Type type = typeof(string[]);
// string[], int[], char[], List<MyData>, IList<MyData>, IEnumarable<MyData> =====> console write "True",
// string, int, MyData etc ==== does not write
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IList<>))
{
Type itemType = type.GetGenericArguments()[0];
Console.WriteLine("True");
}
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List<>))
{
Type itemType = type.GetGenericArguments()[0];
Console.WriteLine("True");
}
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(IEnumerable<>))
{
Type itemType = type.GetGenericArguments()[0];
Console.WriteLine("True");
}
if (type.IsArray)
{
Console.WriteLine("True");
}
}
}
public class MyData
{
public string Name { get; set; }
}