C
Craig Buchanan
I have a class that inherits NameObjectCollectionBase called Products. In
the class' constructor, I add items using BaseAdd(key,value), where key is a
string representation of an id and value an instance of another class called
Product. For example:
Me.BaseAdd(Id,New Product(Id, Name, Price))
In another class, I would like to Enumerate the contents of the Products
class like so:
Dim product As Product
For Each product In Products
Response.Write(product .Id & ":" & product .Name & ":" & product .Price
& "<BR>")
Next
Unfortunately, when the code hits the line For Each product In Products, I
get an error that reads:
Specified cast is not valid.
It appears that the product is actually a string, not the object. What am I
doing incorrectly?
Thanks,
Craig Buchanan
the class' constructor, I add items using BaseAdd(key,value), where key is a
string representation of an id and value an instance of another class called
Product. For example:
Me.BaseAdd(Id,New Product(Id, Name, Price))
In another class, I would like to Enumerate the contents of the Products
class like so:
Dim product As Product
For Each product In Products
Response.Write(product .Id & ":" & product .Name & ":" & product .Price
& "<BR>")
Next
Unfortunately, when the code hits the line For Each product In Products, I
get an error that reads:
Specified cast is not valid.
It appears that the product is actually a string, not the object. What am I
doing incorrectly?
Thanks,
Craig Buchanan