English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hi....
I have class like below.... I'm using VB.NET

public class Person
private id, name as String
End class

I'm using ArrayList of class Person.
How do I find the id or name from class Person in ArrayList ??
How do I select id or name from class Person in ArrayList ??
please help me

thank's for reading....

2007-07-15 19:50:31 · 2 answers · asked by Fadi m 1 in Computers & Internet Programming & Design

2 answers

Because you have defined the variables id and name as private I think this means that they are not available outside the class.
You need to define a getter or setter method that will get or set each of the variables.

So you should then be able to access the array element by
data = arrayListItem(n).getName()
or
idValue = arrayListItem(n).getId()

2007-07-15 20:29:14 · answer #1 · answered by AnalProgrammer 7 · 0 0

Imports System
Imports System.Collections

Public Class MainClass
Shared Private integerValues As Integer() = {1, 2, 3, 4, 5, 6}

Shared Private integerValuesCopy(6) As Integer

Public Shared Sub Main()
Dim result As Integer

Console.WriteLine("Initial Array Values:" )
PrintArray()

Array.Copy(integerValues, integerValuesCopy,integerValues.Length)

Console.WriteLine("Array values after Copy:" )

PrintArray()

result = Array.BinarySearch(integerValues, 5)

If result >= 0 Then
Console.WriteLine("5 found at element " & result )
Else
Console.WriteLine("5 not found" & " in integerValues")
End If

End Sub
Shared Private Sub PrintArray()
Dim integerElement As Integer

For Each integerElement In integerValues
Console.WriteLine(integerElement )
Next

Console.WriteLine(" integerValuesCopy: ")

For Each integerElement In integerValuesCopy
Console.WriteLine(integerElement )
Next

End Sub

End Class

2007-07-16 03:35:19 · answer #2 · answered by Bunny 2 · 0 0

fedest.com, questions and answers