I have an interface through which I want to implement GPU computing. I’m working with ILGPU, which can work with functions containing only unmanaged types.
Example function:
public static void Calculate<D>(int[] buffer, D drawer)
where D : struct, IDrawer
The good news is that you can implement interfaces to structs, but the bad news… due to strong typing, I can’t pass an argument to a method that is unchecked, and because of the syntax, I can’t set such a constraint to property, fields so that they are structs, nor check that the current value is a struct.
//Don't work:
public D Drawers where D : struct, IDrawer { get; set; }
if (Drawer is struct s) { }
Calculate(buffer, Drawer);
FolderMaster is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.