I have just started to learn about OOP and I am wondering if it is possible to create objects using a list rather than an array. The list seems to have oodles of methods that are really useful and can be of an indeterminate length
So, this is what I have
'establish properties / members
Public firstname As String
Public surname As String
Public DOB As Date
'declare a variable of the data type above to put aside memory
Dim students As List(Of STUDENT)
Dim selection As Char
While selection <> "C"
Console.WriteLine("Welcome to student database")
Console.WriteLine("Number of students: " & students.Count)
Console.WriteLine(" (A) Add a student")
Console.WriteLine(" (B) View a student")
Console.WriteLine(" (C) Quit")
selection = Console.ReadLine.ToUpper
If selection = "A" Then
Console.Write("Please enter a firstname: ")
There are multiple issues with this line:
Breaking it down we have:
add = Console.ReadLine
You need a student object first.
students.firstname doesn't exist.
Dim tempStudent = New STUDENT() tempStudent.firstname = Console.ReadLine() ' Other property assignments, etc
Once you have fully created your student object, you then add it to the list. Add is a method so we use parentheses:
Besides that there are a few casing errors which you should address.