Link to home
Start Free TrialLog in
Avatar of F-J-K
F-J-KFlag for Canada

asked on

Array of Variables vs. Array of Object - VB.NET

1. Can you please explain the differences between the following array declarations and which is declaration correct?

    Private courseList As Course() = New Course(5) {}
    Private courseList(5) As Course()

2. I want i know is both declarations allow courseList to carry a reference to the actual object.

3. What about this one: Dim values() As Integer = {1, 2, 3}
Integer is a class, so what values will hold in here? Will it hold the actual number (1,2,3) or their references? If values hold the actual numbers 1,2,3 then Integer is not a class datatype, its a primitive because as i know array can hold actual values of primitive datatype values. Can you please clarify..

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of F-J-K

ASKER

"Integer is a value type (primitive) so it just holds the values."

What about String? There is String and string. Dim values As String = New String(3) {"xxx", "yyy", "zzz"}
Will these 3 values be stored as they are?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of F-J-K

ASKER

Ok. Is String considered as a primitive datatype? What i know primitive datatype doesn't have attributes/behaviors. String variable can call various methods such as Substring, trim, etc, so to me
i see String as a class.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of F-J-K

ASKER

Ok, what gets stored in values? (Dim values() As String = {"xxx", "yyy", "zzz"})
values(0) carries "xxx"? or carries a reference to "xxx"? I hope my question is clear
Avatar of F-J-K

ASKER

Discard my last question. Thanks
Avatar of F-J-K

ASKER

Thanks. Discard my last question