I have the list which i would like to map to List.
However, there is no compiler error, but at runtime result is coming as null.
Getting a generic List<T> will help me make my code generic and reuse for different objects.
private static List<T> GetIndexData(DataAdapter dataAdapter)
{
Type type = typeof(T);
List<T> result = new List<T>();
if (typeof(Category).IsAssignableFrom(typeof(T)))
{
var output = ItemStoreDataManager.GetAllCategoryNames(dataAdapter);
result = output as List<T>;
}
return result;
}
Above code result is coming as null.
internal static List<Category> GetAllCategoryNames(DataAdapter dataAdapter)
{
List<Category> result = new List<Category>();
...........
return result;
}
Please help.
Thanks
TandUare assigment compatible, it does not automatically mean thatList<T>andList<U>are assignment compatible as well.