I have structure defined below:
[StructLayout(LayoutKind.Explicit, Size = 10)]
public struct AudioSampleInfo
{
[FieldOffset(0)]
public ushort AudioBitPerSample;
[FieldOffset(2)]
public ushort AudioNumChannels;
[FieldOffset(4)]
public ushort AudioType;
[FieldOffset(6)]
public uint AudioSampleRate;
}
However, during execution the values seem to change. It seems as if the assigned byte array in memory seem to be overlapping.
During program execution when we set the values as:
AudioSampleInfo audioInfo = new AudioSampleInfo();
audioInfo.AudioBitPerSample = 16;
audioInfo.AudioNumChannels = 1;
After setting the AudioNumChannels, value of AudioBitsPerSample changes to 272.
I can't seem to find any issues as to why this would be occur .
Any suggestions would be helpful ?