I got an enum:
public enum sprog{
dansk,
svensk,
norsk
}
In a method I would raise an event and use the enum to carry information:
public delegate void BrugerSprogChanged(Object sender, Sprog sprog);
class clazz
{
public event BrugerSprogChanged brugerSprogChanced;
public clazz(){}
private void comboBoxDokumentSprog_SelectedIndexChanged(object sender, EventArgs e)
{
Sprog sprog = FindSprog((string)((ComboBox)sender).SelectedItem);
dokumentSprogChanged(this, sprog); // <- here we have the problem
}
}
When the code shall raise the event I get an exception when dokumentSprogChanged(this, sprg) is called:
*"NullReferenceException was unhandled by user code
Object reference not set to an instance of an object"
"this" and "sprog" are not null.
Any suggestions?
The easy way is to drop the unem and use an integer/string instead, but then I end up with some ugly code.