I'm trying to write a generic method which takes in a list of XLCellValue
objects and return a list of nullable generic types. First I tried this:
T? ConvertColumnToNullableType<T?>(List<XLCellValue> inputList)
{
List<T?> outputList = new List<T?>();
return outputList;
}
Which threw the error below:
error CS1003: Syntax error, ',' expected
Then I looked around a bit and tried this:
List<Nullable<T>> ConvertColumnToNullableType<T>(List<XLCellValue> inputList) where T : class
{
List<T> outputList = new List<T>();
return outputList;
}
Which didn't work either:
(1,19): error CS0453: The type 'T' must be a non-nullable value type in order to use it as > parameter 'T' in the generic type or method 'Nullable'
(5,12): error CS0029: Cannot implicitly convert type 'System.Collections.Generic.List' > to 'System.Collections.Generic.List<T?>'
What am I doing wrong here and how can I fix it?