In C# it’s possible to cast to List<T> – so if you have:
List<Activity> _Activities;
List<T> _list;
The following will work:
_list = _Activities as List<T>;
but the translated line with VB.NET which is:
_list = TryCast(_Activities, List(Of T))
throws a compilation error. So I’ve had a good hunt around and experimented with LINQ to find a way round this to no avail. Any ideas anyone?
Thanks
Crispin
I repro, this should technically be possible. Clearly the compiler doesn’t agree. The workaround is simple though:
Or as a one-liner:
The JIT compiler should optimize the temporary away so it doesn’t cost anything.