Arrays VB.net是否从类创建的数组中检索特定值?

Arrays VB.net是否从类创建的数组中检索特定值?,arrays,vb.net,class,Arrays,Vb.net,Class,我有一门课叫“会计”。代码如下: Public Class Account Private accounttype As String Private accountnumber As Integer Private branchcode As String Private currency As String Private balance As Integer Public Sub New() accounttype = " " accountnumber = 0

我有一门课叫“会计”。代码如下:

 Public Class Account
Private accounttype As String
Private accountnumber As Integer
Private branchcode As String
Private currency As String
Private balance As Integer

Public Sub New()
    accounttype = " "
    accountnumber = 0
    branchcode = " "
    currency = " "
    balance = 0
End Sub
Public Sub New(ByVal cu As String, ByVal na As Integer, ByVal su As String, ByVal a1 As String, ByVal a2 As Integer)
    accounttype = cu
    accountnumber = na
    branchcode = su
    currency = a1
    balance = a2
End Sub
Public ReadOnly Property Getaccountnumber() As String
    Get
        Return accountnumber
    End Get
End Property

Public ReadOnly Property Getbalance() As Integer
    Get
        Return balance
    End Get
End Property

Public Overrides Function ToString() As String
    Return "Account Type: " & accounttype & vbCrLf & "Account Number: " & accountnumber.ToString & vbCrLf & "Branch Code: " & branchcode & vbCrLf & "Currency: " & currency & vbCrLf & "Balance: " & balance.ToString

End Function


End Class
然后我硬编码了一些这样的账户

    Dim account1 As New Account("Savings", "1", "S1", "Khajalee", 1000)
    accodetails.Add(account1)
我想知道如何从数组中获取帐户的“余额”值。任何帮助都太好了!!正如你所看到的,我试着用一些不同的代码来平衡,但是没有运气

谢谢

提供,您所说的“数组”是指
accodetails
,然后您可以通过索引访问数组中的任何项目,如下所示:

Dim myAccount As Account = accodetails(0)
Dim myBalance As Integer = myAccount.GetBalance
Dim myBalance As Integer = accodetails(0).GetBalance
然后,您可以通过该变量访问
帐户
对象中的任何属性,如下所示:

Dim myAccount As Account = accodetails(0)
Dim myBalance As Integer = myAccount.GetBalance
Dim myBalance As Integer = accodetails(0).GetBalance
或者,更简单地说,您可以直接从列表中的项访问属性,而无需将其分配给变量,如下所示:

Dim myAccount As Account = accodetails(0)
Dim myBalance As Integer = myAccount.GetBalance
Dim myBalance As Integer = accodetails(0).GetBalance

快速提问,在向余额中添加资金后,我将如何永久改变该值?谢谢,我不明白你的意思。如您所示,该类不允许更改其平衡。