While working on the project, I realized that there is something that I really do not know about C # (and I can not find anything about it in google). If you assign a value to a variable (which has already been initialized with a default value), and the value is created by another method, what will happen if you get an exception in another method. For clarification, here is an example:
eType = defaultvalue;
...
eType = (EReaderType)Enum.Parse(typeof(EReaderType), tXmlNode.InnerText, true);
What happens if Enum.Parse fails to parse the value (a string in Xml, not relevant here ...) and throw an exception? Will eType keep the default value or reassign something else (zero or some undefined blabla)? So far, my tests show that it will retain the old value. However, I'm not sure if this will work all the time or if it happens by accident. Simply put, I don't know how C # handles this stuff.
Edit: Ok, thanks for all the answers :)
source
share