No it isn't. The internal layout of a class or struct is undiscoverable. Marshaling is required, guided by a StructLayout, to convert that undocumented layout to a known one.
The JIT compiler readily takes advantage of this, it re-orders the fields in a struct for example to get them properly aligned and require the minimum of storage. This defeats any tricks that messes with unmanaged pointers. The simple value types behave predictably, but they are already well covered by BitConverter.
Structures are your nemesis.
No it isn't. The internal layout of a class or struct is undiscoverable. Marshaling is required, guided by a StructLayout, to convert that undocumented layout to a known one.
The JIT compiler readily takes advantage of this, it re-orders the fields in a struct for example to get them properly aligned and require the minimum of storage. This defeats any tricks that messes with unmanaged pointers. The simple value types behave predictably, but they are already well covered by BitConverter.
Structures are your nemesis. This is one reason why it took so long for memory-mapped files to be supported by the . NET framework.
But they'll be available in . NET 4.0, you could take advantage of the MemoryMappedViewAccessor class. It still uses marshaling, it is hidden under the floor mat.
I will look into MemoryMappedViewAccessor as soon as new framework will be officialy released, thank you – Drake Apr 7 '10 at 16:15.
I have found the following code works in VB. NET, but not in C#. If generics aren't allowed when using BitConverter.GetBytes() why does the VB code work?
Can anyone explain that for me? VB. NET version (works): Public Class TestClass(Of T) Public Sub Test(ByVal data As T) Dim temp As Object = data Dim byteData As Byte() = BitConverter.
GetBytes(temp) End Sub End Class C# version (does not work): public class TestClass { public void Test(T data) { Object temp = data; Byte byteData = BitConverter. GetBytes(temp); } }.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.