还是个.NET问题,关于更改类属性
情况是这样的:
我定义了一个类CheatEngineConfigReadAndWrite
然后用如下代码初始化了数组(可见性为PUBLIC)
Dim ConfigInfo() As CheatEngineConfigReadAndWrite
ReDim ConfigInfo(mIndex) 'mIndex是常量
而后调用如下函数(无关部分已省略)
private sub SetValue ()
Dim CI As CheatEngineConfigReadAndWrite
For Each CI In ConfigInfo
CI.ThenEditOver = True '该属性默认为假
Next
end sub
接下来就比较郁闷,为什么上面的代码没有更改ThenEditOver属性呢?
private sub GetValue ()
Dim CI As CheatEngineConfigReadAndWrite
For Each CI In ConfigInfo
debug.print(CI.ThenEditOver) '该属性默认为假
Next
end sub
输出结果非常令人满意,,全是False。。。。请高人指点啊。。。
开始我以为我定义CI时使用NEW关键字不对,可是去掉NEW还是这德行。
类内部是这样实现该属性的:
Private m_ThenEditOver As Boolean '私有变量
Public Property ThenEditOver() As Boolean '公有属性
Get
Return m_ThenEditOver
End Get
Set(ByVal value As Boolean)
m_ThenEditOver = value
End Set
End Property
难道更改ConfigInfo()里某个元素的属性使用其他方法吗??
[解决办法]
try:
private sub GetValue ()
Dim CI As CheatEngineConfigReadAndWrite
For Each CI In ConfigInfo
ci=new CheatEngineConfigReadAndWrite '这个加上试试
CI.ThenEditOver = True '该属性默认为假
console.writeLine(CI.ThenEditOver)
NextNext
end sub