I think this should be a very simple test but I can't figure out what the
problem is:
Imports ConsoleApplicat ion1.FruitDetai ls
Public Class FruitDetails
Private m_fruitInfo As IDictionary(Of String, FruitColor)
Public Property FruitInfo()
Get
Return m_fruitInfo
End Get
Set(ByVal value)
m_fruitInfo = value
End Set
End Property
Public Enum FruitColor
orange
yellow
green
End Enum
End Class
Module Module1
Sub Main()
Dim Detail As New FruitDetails
Dim Fruit As New Dictionary(Of String, FruitColor)
Fruit.Add("Bana na", FruitColor.yell ow)
Detail.FruitInf o = Fruit
Console.Write(G etFruit(Detail) )
End Sub
Public Function GetFruit(ByVal FruitInformatio n As FruitDetails) As
String
Try
For Each Fruit As DictionaryEntry In FruitInformatio n.FruitInfo
'specific cast is not valid
Return String.Concat(" This ", Fruit.Key, "Is ", Fruit.Value)
Next
Catch ex As Exception
Console.Write(e x.ToString)
End Try
End Function
End Module
The information I'm really looking for is the first DictionaryEntry in
DetailLevel without having to do a For Each loop ... maybe
IEnumerator.Ent ry?
Thanks
problem is:
Imports ConsoleApplicat ion1.FruitDetai ls
Public Class FruitDetails
Private m_fruitInfo As IDictionary(Of String, FruitColor)
Public Property FruitInfo()
Get
Return m_fruitInfo
End Get
Set(ByVal value)
m_fruitInfo = value
End Set
End Property
Public Enum FruitColor
orange
yellow
green
End Enum
End Class
Module Module1
Sub Main()
Dim Detail As New FruitDetails
Dim Fruit As New Dictionary(Of String, FruitColor)
Fruit.Add("Bana na", FruitColor.yell ow)
Detail.FruitInf o = Fruit
Console.Write(G etFruit(Detail) )
End Sub
Public Function GetFruit(ByVal FruitInformatio n As FruitDetails) As
String
Try
For Each Fruit As DictionaryEntry In FruitInformatio n.FruitInfo
'specific cast is not valid
Return String.Concat(" This ", Fruit.Key, "Is ", Fruit.Value)
Next
Catch ex As Exception
Console.Write(e x.ToString)
End Try
End Function
End Module
The information I'm really looking for is the first DictionaryEntry in
DetailLevel without having to do a For Each loop ... maybe
IEnumerator.Ent ry?
Thanks
Comment