Invalid cast error

Hi,

I got the following piece of C# code that I am porting over from VS. When compiling in Water I get an “Invalid cast” error:

public static List ToList(this IDataReader dr)
{
var result = new List();
var listType = typeof(List);
while (dr.Read())
{
if (listType == typeof(List))
{
(result as List)?.Add(dr.ToString(0)); // **** Invalid cast here
}
if (listType == typeof(List))
{
(result as List)?.Add(dr.ToInt(0)); // **** Invalid cast here
}
}

Is there a way to code it so it compiles in Water?

// Thom

Can I get some more context for this, or ideally a full project? e.g. what is List, there’s not non-generic type called List in standard .NET, as far as I can see?

Thanks, logged as bugs://85004

bugs://85004 got closed with status fixed.