Was writing a new method to open a custom dialog box I created, and realized that the other method I wrote to open another custom dialog had the same name as the object representing it, but there was no error?
This is what I mean:
Originally the code read:
Dialogs.Accounts.NewLocation LocationEditor = new Dialogs.Accounts.NewLocation(); LocationEditor.ShowDialog();
And after the editor evolved I decided to reuse the same form for creating new locations and editing existing ones, so to make the name of the form match it's purpose I changed it from NewLocation to LocationEditor. Now the code reads:
Dialogs.Accounts.LocationEditor LocationEditor = new Dialogs.Accounts.LocationEditor(SelectedLocation, false); LocationEditor.ShowDialog();
There's no error with this? I don't get it, I thought this wasn't allowed? The object's name is LocationEditor and the instance of that object is LocationEditor...same name, same casing...I'm confused, if the method was longer than about 6 lines and the object was used over and over, how would the compiler know what I was talking about, the original object or the instance that already exists? Either way I'm going to change the name of the instance, but I just never caught this until now and just found it odd that it worked.