I have a piece of code as follows: it retrieves a Json string, parses it, and if required sets the value in the specific node:
JObject jObject = JObject.Parse(JsonString);
dynamic dModel = jObject;
var url = dModel.Value<string>("Urllink");
How can I change this to something like below by using the ?
expression?
if (string.IsNullOrEmpty(url))
url = url;
else
url = "#_urlString";
How can I make lines 1 - 5 more efficient?
CodePudding user response:
url=string.IsNullOrWhiteSpace(url) ? url : "#_urlString";