I have Windows form C# application that takes values from the GUI and uses XML Textwriter to create an XML file from them. The problem is some of these values are meant to be optional and when the user leaves them blank, the application gets a null reference exception because the text stream is null. Without doing a check on every value, is there a way to exception handle the whole thing to ignore null values? Try-catch doesn't seem work in this regard because it won't return the cursor to the next statement. Sorry if this is a n00bish question!
Skip item if null for xml text writer
611 views Asked by Benjamin Barkhouse At
2
Using exceptions to handle this will lead to all sorts of issues. You need to spend the time to wrap the calls to
writer.Write(....)
withif(...)
for values that are not required.