D
D Browne
I think this should be a very simple test but I can't figure out what the
problem is:
Imports ConsoleApplication1.FruitDetails
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("Banana", FruitColor.yellow)
Detail.FruitInfo = Fruit
Console.Write(GetFruit(Detail))
End Sub
Public Function GetFruit(ByVal FruitInformation As FruitDetails) As
String
Try
For Each Fruit As DictionaryEntry In FruitInformation.FruitInfo
'specific cast is not valid
Return String.Concat("This ", Fruit.Key, "Is ", Fruit.Value)
Next
Catch ex As Exception
Console.Write(ex.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.Entry?
Thanks
problem is:
Imports ConsoleApplication1.FruitDetails
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("Banana", FruitColor.yellow)
Detail.FruitInfo = Fruit
Console.Write(GetFruit(Detail))
End Sub
Public Function GetFruit(ByVal FruitInformation As FruitDetails) As
String
Try
For Each Fruit As DictionaryEntry In FruitInformation.FruitInfo
'specific cast is not valid
Return String.Concat("This ", Fruit.Key, "Is ", Fruit.Value)
Next
Catch ex As Exception
Console.Write(ex.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.Entry?
Thanks