PDA

View Full Version : آرایه از کلاس



مجتبی کریمی
یک شنبه 02 اردیبهشت 1386, 12:29 عصر
با سلام
به تعریف این کلاس نگاه کنید.



Public Class clsSection

Dim _Name As Integer
Dim _A As Single
Dim _I_x As Single
Dim _r_x As Single

Public Property A() As Single
Get
Return _A
End Get
Set(ByVal value As Single)
If value > 0 Then
_A = value
End If
End Set
End Property

Public Property I_x() As Single
Get
Return _I_x
End Get
Set(ByVal value As Single)
If value > 0 Then
_I_x = value
End If
End Set
End Property

Public ReadOnly Property r_x() As Single
Get
If I_x > 0 And A > 0 Then
_r_x = Math.Sqrt(I_x / A)
Return _r_x
End If
Return Nothing
End Get
End Property

End Class

من می خواهم یه آرایه از این کلاس داشته باشم ولی خوب تو VB .net 2 نمیشه .
آیا جور دیگه ای می تونم این ساختارو داشته باشم و بتونم از اون آرایه تعریف کنم؟

saeed_rezaei
یک شنبه 02 اردیبهشت 1386, 15:05 عصر
من با استفاده از کد زیر یه آرایه 5 تایی از کلاس شما ساختم



Dim m(5) As clsSection

m(0) = New clsSection
m(0).A = 15

m(1) = New clsSection
m(1).A = 20

m(2) = New clsSection
m(2).A = 18

m(3) = New clsSection
m(3).A = 11

m(4) = New clsSection
m(4).A = 40

MsgBox(m(0).A)