Is there an existing issue for this?
Describe the bug
Code snippet:
ArrayList list = new ArrayList();
list.Add(Day.Monday);
var array = list.ToArray(typeof(Day));
public enum Day { Monday, Tuesday }
This is working fine in .net 6 desktop. But in Blazor WebAssembly, it throws exception System.InvalidCastException: At least one element in the source array could not be cast down to the destination array type.
list.ToArray() without type is fine. But we are using type which is loaded in runtime, so the type is required.
Expected Behavior
Array created without exception
Steps To Reproduce
https://github.com/jjzhang12/WasmToArrayIssue.git
I added above code snippet to index page and you can observe the exception.
Also the .net console app is working fine.
Exceptions (if any)
System.InvalidCastException: At least one element in the source array could not be cast down to the destination array type.
.NET Version
6.0.101
Anything else?
No response