奇怪的問題我的代碼(.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