Casting a Custom Class

Apr 5 2004 9:35 PM
Hi, I have a problem regarding casting a custom class I created. The situation is this... I created a menu item in the mdi with a corresponding click eventhandler, I passed a certain parameter on this menuitem by using a custom class I created that inherited a MenuItem class. the codes of the class I created is shown below: using System; using System.Windows.Forms; namespace WarehouseMDI { public class MenuItemEx : MenuItem { private string assemblyname; public MenuItemEx() { } public string AssemblyName { get{return assemblyname;} set{assemblyname = value;} } } } on the menu item click event: private void Menu_Clicked(object sender, EventArgs e) { MenuItemEx item = (MenuItemEx) sender; <---Specified Cast not valid MessageBox.Show(item.AssemblyName); } when I use the quick watch on the sender parameter, the AssemblyName is there with its corresponding value. How can I cast this object so that I may be able to view the custom property I created? Any help would be greatly appreciated! thanks, Chris