I have a base class, Item, and 3 derived classes: Weapon, Shield, Armor.
I've created a listbox and populated it with all three of the derived classes.
My question is, how can I access the properties values of the class when I select it in the list box? I've tried:
dynamic weapon = Convert.ChangeType(item, typeof(Weapon));
But weapon doesn't give me access to the properties values. I see the same intellisense options as if I do:
var item = LstStoreItems.SelectedItem;
The goal I'm trying to accomplish is selecting an object from the list box, and populating some labels based upon the object selected.
EXAMPLE
A Weapon has a Name, Attack, Type, and Cost. A Shield has Name, Defense, Material, and Cost. Whenever I select a Weapon, I want to populate labels on my form to display this information to the user. When I select a Shield, I want to display that information.