I dumbed down my code a lot so that it is easier to see the issue. When I compile, I get the error:
The type 'T' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'System.IO.UnmanagedMemoryAccessor.Write<T>(long, ref T)'
Code block is below. I suspect it is a simple thing, just because I am unfamiliar with generics. Feedback would be most appreciated.
class BigArrayGeneric<T> { private System.IO.MemoryMappedFiles.MemoryMappedFile mmf; public BigArrayGeneric() { mmf = System.IO.MemoryMappedFiles.MemoryMappedFile.CreateNew("MMF_File", 1024); } public void Initialize(T val) { Int64 itemsInitialzed = 0; using (var accessor = mmf.CreateViewAccessor(itemsInitialzed, 1024)) { accessor.Write(0, true); accessor.Write(1, ref val); // Can't make this compile } return; } }