Mike Eghtebas
asked on
Use List(of Type)
Below, stying with:
Dim value As New List(Of Importance)
Or modifying it a bit, I want to print the items in Enum Importance. I want to practice the use List(of Type).
This code doesn't work. Could you please help to make it work possibly using the above objective.
Dim value As New List(Of Importance)
Or modifying it a bit, I want to print the items in Enum Importance. I want to practice the use List(of Type).
This code doesn't work. Could you please help to make it work possibly using the above objective.
Enum Importance
Critical = 4
Important = 3
None = 0
Regular = 2
Trivial = 1
End Enum
Private Sub Enum_Select_TypoOf()
Dim value As New List(Of Importance)
Dim i As Integer
For i = 0 To value.Count
Console.WriteLine(value(i))
Next i
Console.ReadLine()
End Sub
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
kaufmed is thinking the same way as I - the enum itself is no good example. It is like having only prizes, without any article description. If course you can sort them, but what does the result mean then?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks to all. I had easier solution to print Enum Importance. My goal was to wrap my mind around use of List(Of Type). Kaufmed explanation was helpful.
It_saige's solution brings me to a point where I can see how use of List maybe is not the best use in this case. I will try List(Of Type) with other settings to learn more about it.
Mike
It_saige's solution brings me to a point where I can see how use of List maybe is not the best use in this case. I will try List(Of Type) with other settings to learn more about it.
Mike
ASKER
Here is an example of what I was looking for:
Enum Code As Byte
Small = 0
Medium = 1
Large = 2
End Enum
Sub Main()
Enum_Types() 'http://www.dotnetperls.com/enum-vbnet
End Sub
Private Sub Enum_Types()
' The value is represented in a byte.
Dim value As Code = Code.Medium
'Console.WriteLine(value)
For Each i In [Enum].GetValues(GetType(Code))
Console.WriteLine(i)
Next
Console.ReadLine()
End Sub
Output:
small
medium
large