2012-03-29 16 views
2

現在、私はWAVファイルを扱うアプリケーションを開発中です。構造体にそのネイティブ型の情報を表示できるようにしたいが、C#はcharを16ビット値と考える。Visual Studioのデバッグ - ネイティブタイプ

ChunkID0 ... 3 'R' 'は、私は' の代わりに122のR ' '私は、デバッガとして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'' Fが含まれていることになっている4つのバイト。

どのような考えですか?

+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; 
} 
関連する問題