If I have a string result="Out of Service"
.And I want to update it to its short form if it matches with full name by comparing with a list that has values like attached image :
How can I do that?
CodePudding user response:
Using Linq
var result = "Out of Service";
result = shortForms.FirstOrDefault(model => model.Name == result)?.ShortName ?? result;