- C#, C♯, C#相談室 Part94
23 :デフォルトの名無しさん (ワッチョイ cb84-S3x4)[sage]:2020/04/06(月) 18:03:23.76 ID:7X8pPa4E0 - 2度手間っていうか面倒くさいけどStructureToPtrでバイトストリームに一括で変換するのが
目的ならば、外に見せる部分はclassで作っておいて中にstructを定義する structの要素にはプロパティでget/setする初期値はclassのコンストラクタで設定 classにバイトストリームを取り出す(StructureToPtrに絡むロジック)メソッドかプロパティを 定義するみたいなのじゃダメなのかな class point { public point () { x = 0; y = 0; } private _point _Struct; public int x { get { return _Struct.x; } set { _Struct.x = value; } } public int y { get { return _Struct.y; } set { _Struct.y = value; } } public byte[] bytestream { get { return structToPtrFunc(_Struct); }//メソッドは別途作成 } [StructLayout(LayoutKind.Sequential)] private struct _point { int x; int y; } }
|
|