Problem with type casting?

The following is my extension method to cast types

public static T Cast<T>(this object obj)
{
	return (T)obj;
}

This is my extension to convert list to array:

public static List<Transform> ToTransformList(this List<WaypointData> waypointsDataList)
	{
		List<Transform> waypoints = new List<Transform>();
		foreach(WaypointData wd in waypointsDataList)
		{
			waypoints.Add(wd.waypoint);
		}
		return waypoints;
	}

I use reflection and in that if i find any filled info of type list i need to convert it to array. The filed info

FieldInfo[] fieldinfos = kamal.GetType ().GetFields();
		foreach(FieldInfo field in fieldinfos)
		try{
			if(field.FieldType.GetGenericTypeDefinition()==typeof(List<>))
			{
                                //kamal actual type of List<String>//    
				    var cast = field.GetValue(kamal);
                               //here i need to make the program understand that this is some kind of list. Only then i can use my ToArray extension method. But the following is not working.
				   var array = cast.Cast<cast.GetType()>().ToArray();
			}
		}
		catch{}

Don’t think you can’t resolve your generics at runtime, as you are trying to do with GetType(). Anyway, here are some pointers that could help.

MakeGenericType will also work with open generic types (as is your case) as stated here.