2012-03-29 4 views
2

현재 WAV 파일로 작업 할 응용 프로그램을 개발 중입니다. 네이티브 형식의 구조체 정보를 표시 할 수 싶습니다 있지만 C# 16 비트 값으로 char 생각합니다. Visual Studio 디버깅 - 네이티브 형식

네 바이트 ChunkID0

은 ... (3) R '대신 122'로 ChunkID을 보여

[StructLayout(LayoutKind.Explicit, Size = 12, Pack = 1)] 
public unsafe struct RiffDescriptor 
{ 
    [FieldOffset(0)] 
    public byte ChunkID_0; 

    [FieldOffset(1)] 
    public byte ChunkID_1; 

    ... 
} 

내가 원하는 디버거를 'F가'R ''나 ''F ''를 포함하도록되어있다 .

어떤 생각?

+0

왜 'char'로 선언하지 않습니까? – Jon

+0

어떻게 122를 R에 매핑합니까? – JaredPar

+0

@ Jon C#은 char이 16 비트 유형임을 나타냅니다. 원래 유형을 유지하고 싶습니다. – clamport

답변

1
public class RiffDescriptor 
{ 
    public RiffDescriptor(BinaryReader b) 
    { 
     // Read the ChunkID - Should be RIFF 
     ChunkID = b.ReadBytes(4); 

     // Read the ChunkSize 
     ChunkSize = b.ReadUInt32(); 

     // Read the Format - Should be WAVE 
     Format = b.ReadBytes(4); 
    } 

    [DebuggerDisplay("ChunkID = {System.Text.Encoding.Default.GetString(ChunkID)}")] 
    public byte[] ChunkID; 

    public UInt32 ChunkSize; 

    [DebuggerDisplay("Format = {System.Text.Encoding.Default.GetString(Format)}")] 
    public byte[] Format; 
}