I have a class named Card
with a property of CardNumbers
Private _number As CardNumbers
Public Property Number() As CardNumbers
Get
Return _number
End Get
Set(ByVal value As CardNumbers)
_number = value
End Set
End Property
I have this enum of cards numbers that was used as the property of Card
.
Enum CardNumbers
Ace = 1
Two = 2
Three = 3
Four = 4
Five = 5
Six = 6
Seven = 7
Eight = 8
Nine = 9
Ten = 10
Jack = 11
Queen = 12
King = 13
End Enum
Now, I have a loop to insert CardNumbers
into a Dim Cards As New List(Of Card)
, but I do not know how to add each of the CardNumbers
into the List. Been researching awhile. Can anyone help? Thanks.
UPDATE:
I have now this code to add create an instance of the class Card
and then add to the list of Card called Cards
:
Dim c As New Card()
For Each n As CardNumber.CardNumbers In [Enum].GetValues(GetType(CardNumber.CardNumbers))
c.Number = n
Cards.Add(c)
Next
But then, I get a NullReferenceException
error.