3 ms·
Don't forget you can add an empty constructor constraint in c# generics. public T AssignLiteItem<T>(ArchivingItem archivingItem ) where T : Item, new() { T my
by mindviews 18y ago
Don't forget you can add an empty constructor constraint in c# generics.
public T AssignLiteItem<T>(ArchivingItem archivingItem ) where T : Item, new() {
T myITem = new T();
myITem.ItemReference = new ItemReference(archivingItem.Id);
return myITem;
}
I do wish the compiler handled constraints for arbitrary constructor signatures on generic types, however...
- habs 18y agoNice, I guess I can get rid of the reflection invocation of the T Type constructor. Should speed things up a bit. Cheers.