I have a generated stub for a .net web service which has several string properties. Given some response from the web service, can these properties have a null value or are they always at least converted to a string.Empty?
Are they only possibly null if the ‘nillable=”true”‘ attribute is applied to them in the WSDL?
You see… I want to just start Trim()’ing the values of the properties without getting any null reference exceptions.
A server should serialize a null value as null, not String.Empty, unless there’s some additional logic put in place. If you don’t wanna write a bunch of null checks, consider making an extension method for trim.
Edit: Or go with Anders’ more streamlined version. 🙂