奇怪的问题我的代码(.Net Framework 3.5)中有这个奇怪的问题。所以,在一个正常的VB.NET程序,我会做这样的事情:List(Of T)声明和.add
Dim MyList As New List(Of Integer)
MyList.Add(3)
MyList.Add(5)
MyList.Add(9)
MyList.Add(17)
并经过
Dim MyList As New List(Of Integer)
如果我把一个“突破”分辩,把鼠标放在“MYLIST”,而代码暂停,我应该得到:Count = 0。然而,我有一个子我在那里创建一个列表,并得到(当我打破它后):“计数=财产评估失败”。
似乎如果我的列表没有足够的空间来容纳数据......下面是我用来试验一切的完整代码(顺便说一句,代码本身并不真正有意义,因为它是我的项目)。有了它,我可以创建“怪异”的行为,任何人都可以测试。下面的代码(抱歉的代码块按钮不工作):
Structure lPossibilitiesOutputStruct
Dim Pinion As GearOutputStruct
Dim Gear As GearOutputStruct
Dim Forces As ForcesStruct
Dim CenterDistance As Double
Dim Pitch As Double
Dim lStagePossibilities As List(Of lPossibilitiesOutputStruct)
End Structure
Structure GearOutputStruct
Dim TeethNbr As Integer
Dim RPM As Double
Dim FaceWidth As Double
Dim OutsideDiameter As Double
Dim Addendum As Double
Dim WholeDepth As Double
Dim OperatingPitchDiameter As Double
Dim OverPinData As OverPinOutputStruct
Dim SpanData As SpanOutputStruct
Dim AllowableBendingPower As Double
Dim AllowablePittingPower As Double
End Structure
Structure OverPinOutputStruct
Dim PinDiameter As Double
Dim OverpinMeasurement As Double
End Structure
Structure SpanOutputStruct
Dim TeethNbr As Integer
Dim SpanMeasurement As Double
End Structure
Structure ForcesStruct
Dim GearSetAxialForce As Double
Dim GearSetRadialForce As Double
Dim GearSetTangentialForce As Double
End Structure
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim lStagePossibilities As New List(Of lPossibilitiesOutputStruct)
Dim MyList As New List(Of Integer)
MyList.Add(3)
MyList.Add(5)
MyList.Add(9)
MyList.Add(17)
lStagePossibilities = lGeneratePossibilities(Nothing, Nothing, 3, 1)
End Sub
Private Function lGeneratePossibilities(ByVal ActualStage As lPossibilitiesOutputStruct, ByVal CSL As List(Of Integer), ByVal MaxStage As Integer, ByVal CumulatedRatio As Double) As List(Of lPossibilitiesOutputStruct)
Return Nothing
End Function
我所做的就是创建一个表单一个新项目,并创建了代码。项目中没有别的东西。我玩“有针对性的CPU”,这就是所有...
如果我运行该程序与编译选项使用x86 CPU,并放在“lStagePossibilities = ...”我得到“计数=财产评估失败“,当我把我的鼠标放在MyList上。如果我用x64 CPU运行它,那么一切工作正常......(“Count = 4”)。如果我回到x86 CPU,我会回到错误。更糟糕的是,如果我在lPossibilitiesOutPutStruct结构声明中将“Dim Pinion as GearOutputStruct”行或“Dim Gear as GearOutputStruct”行或“Dim Forces as ForcesStruct”行注释掉,则一切正常,并且x86 CPU ...
它可能与一种列表的最大尺寸有关吗?
谢谢!
让
为什么使用结构?在.Net中使用类除非你有充分的理由不要。 – 2010-12-16 15:52:39