I'm trying to get a string from memory using StrucLayout
and FieldOffset
But I'm having a lot of trouble understanding how byte
works.
Here is my code ATM :
[StructLayout(LayoutKind.Explicit)]
public unsafe struct InfoDetails
{
[FieldOffset(0x14)]
public fixed sbyte Name[50];
public string getName
{
get
{
fixed (sbyte* namePtr = Name)
{
return new string(namePtr);
}
}
}
}
This code returns
: T
. Expected result is TEZ
.
Any advices on why I'm doing it wrong ? Thanks