C++言語で作成した構造体をC#に移植したい
C++
struct SYSINFO {
unsigned short id;
unsigned short cnt;
unsigned short disp;
unsigned short cf;
unsigned short rsv1[4];
unsigned short no[4];
unsigned char sel[4];
unsigned char type[4];
}
main.h
class TSample: public TForm
{
public: SYSINFO sysinfo[64];
main.cpp
TSample *sample;
art.cpp
sample->sysinf[10].id=0x890;
sample->sysinf[10].sel[5]=4;
みたい 使い方します。
C# でも 同じような方法が できないでしょうか?
例
work.cs
public class SysInfoClass{
public UInt16 id;
public UInt16 cnt;
public UInt16 disp;
public UInt16 cf;
public UInt16[] rsv1 = new UInt16[4];
public UInt16[] no =new UInt16[4];
public Byte[] sel= new Byte[4]
public Byte[] type=new Byte[4];
}
main.cs
public static SysInfoClass[] sinfo = new SysInfoClass[64];
sinfo[0].id = 0x980;
sinfo[0].rsv1[0] = 1; <<<< ここで 実行エラー
いろいろ 試しましたが
うまくいきません。
ご教示願います。
※ 一次配列なら うまく動作しますが
二次配列は どうも コンパイルOKでも
DEBUGで エラー
追補:
work.cs
最初から 二次配列にすれば問題ないようですが
public class SysInfoClass{
public UInt16[] id =new UInt16[64];
public UInt16[] cnt=new UInt16[64];
public UInt16[] disp=new UInt16[64];
public UInt16[] cf =new UInt16[64];
public UInt16[,] rsv1 = new UInt16[64,4];
public UInt16[,] no =new UInt16[64,4];
public Byte[,] sel= new Byte[64,4]
public Byte[.] type=new Byte[64,4];
}
この場合
syinfo.id[0]=0x980;
syinfo.rev1[0]=1;
のようになってしまいます
sinfo[0].id = 0x980;
sinfo[0].rsv1[0]=1;
プログラムの都合上
sinfo[0].id = 0x980;
sinfo[0].rsv1[0]=1;
こういう使い方をしたいのです