I've got this nifty little piece of code here that self-propogates ad infinitum every time the relevant method is called:
if (this.ListBox_MyListBox.Items[e.Index] is MyObject)
{
MyObject epicObject= new MyObject();
epicObject= (MyObject)this.ListBox_MyListBox.Items[e.Index];
epicObject.Name = epicObject.Name + " (label)";
The method in question is a click event, and unfortunately, every time I click, it adds another " (label)" to the end of the name string.
Elsewhere, I have a very similar situation which doesn't need a cast
if (this.ListBox_MyListBox.Items[e.Index] is String)
{
string tag = (string)this.ListBox_SmartSetOptions.Items[e.Index]+ " (tag)";
and that code works fine.
I had thought that declaring a new object each time would avoid the endless repetition, but its still happening. What am I missing?