I'm receiving some data from the client in the form of json. I'm writing this:
string TheText; // or whould it be better string TheText = ""; ? TheText = ((serializer.ConvertToType<string>(dictionary["TheText"])).Trim());
If the variable that's being parsed from json comes back empty, does this code crash when I call the .Trim() method?
Thanks.
You can use elvis operator:
GetNullableString()?.Trim(); // returns NULL or trimmed string
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With