Parameters(MAX_PARAMETERS - 1) As InstructionParam,这是定义数组 InstructionParam[] Parameters=new InstructionParam[MAX_PARAMETERS - 1];
OpCode(MAX_OPCODE_LEN - 1) As Byte Byte[] OpCode=new Byte[MAX_OPCODE_LEN - 1];
Public Type Instruction Mnemonic As String Prefixes As OpCodePrefixes OpCode(MAX_OPCODE_LEN - 1) As Byte OpCodeLen As Long RegOpExt As Long ModRM As Boolean Parameters(MAX_PARAMETERS - 1) As InstructionParam ParamCount As Long Now3DByte As Long End Type这里定义一个名为Instruction的结构体,结构体也是一种类型,只不过是可以包含多个成员变量的类型 Parameters(MAX_PARAMETERS - 1) As InstructionParam表示该结构体里面有一成员数组其长度为 MAX_PARAMETERS - 1,可以通过Dim Example As Instruction '实例化对象 Example.Parameters(i) '可以通过这样的方式去访问这个结构体的数组 ReDim 为数组变量重新分配存储空间。可选项修饰符 Preserve 当仅更改最后一个维度的大小时,用来保留现有数组中的数据。'有一个Byte数组A,如果我们知道这个数组上限最大只能是4,就用Dim Dim A As Byte(4) '但如果我们不能事先确定它的大小,或者需要在运行时改变它的大小就要用动态数组 Dim A As Byte() ReDim A(4) '这样改变大小时会清空原来的数据 ReDim Preserve A(4) '这样改变大小时会保留原来的数据
这个转的是vb.net到C#我的代码是vb不一样
private const long MAX_OPCODE_LEN = 4; private struct OpCode { byte[] Bytes; long ByteCount; long RegOpExt; } public struct InstructionParam { ParamType PType; ParamSize Size; ASMRegisters Register; ASMFPURegisters FPURegister; ASMXMMRegisters MMRegister; long Value; bool Forced; } public struct Instruction { string Mnemonic; OpCodePrefixes Prefixes; byte[] opCode; long OpCodeLen; long RegOpExt; bool ModRM; InstructionParam[] Parameters; long ParamCount; long Now3DByte; } 大概是这样的吧,细微之处再微调下
ReDim Preserve Instructions(InstructionCount) As Instruction还有这种vb是什么意思?
http://www.developerfusion.com/tools/convert/vb-to-csharp/
InstructionParam[] Parameters=new InstructionParam[MAX_PARAMETERS - 1];
Byte[] OpCode=new Byte[MAX_OPCODE_LEN - 1];
Public Type Instruction
Mnemonic As String
Prefixes As OpCodePrefixes
OpCode(MAX_OPCODE_LEN - 1) As Byte
OpCodeLen As Long
RegOpExt As Long
ModRM As Boolean
Parameters(MAX_PARAMETERS - 1) As InstructionParam
ParamCount As Long
Now3DByte As Long
End Type这里定义一个名为Instruction的结构体,结构体也是一种类型,只不过是可以包含多个成员变量的类型
Parameters(MAX_PARAMETERS - 1) As InstructionParam表示该结构体里面有一成员数组其长度为
MAX_PARAMETERS - 1,可以通过Dim Example As Instruction '实例化对象
Example.Parameters(i) '可以通过这样的方式去访问这个结构体的数组
ReDim 为数组变量重新分配存储空间。可选项修饰符 Preserve 当仅更改最后一个维度的大小时,用来保留现有数组中的数据。'有一个Byte数组A,如果我们知道这个数组上限最大只能是4,就用Dim
Dim A As Byte(4)
'但如果我们不能事先确定它的大小,或者需要在运行时改变它的大小就要用动态数组
Dim A As Byte()
ReDim A(4) '这样改变大小时会清空原来的数据
ReDim Preserve A(4) '这样改变大小时会保留原来的数据
private const long MAX_OPCODE_LEN = 4; private struct OpCode
{
byte[] Bytes;
long ByteCount;
long RegOpExt;
}
public struct InstructionParam
{
ParamType PType;
ParamSize Size;
ASMRegisters Register;
ASMFPURegisters FPURegister;
ASMXMMRegisters MMRegister;
long Value;
bool Forced;
}
public struct Instruction
{
string Mnemonic;
OpCodePrefixes Prefixes;
byte[] opCode;
long OpCodeLen;
long RegOpExt;
bool ModRM;
InstructionParam[] Parameters;
long ParamCount;
long Now3DByte;
}
大概是这样的吧,细微之处再微调下