Reputation: 7
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?
Upvotes: 0
Views: 164
Reputation: 2605
Using Linq
var result = "Out of Service";
result = shortForms.FirstOrDefault(model => model.Name == result)?.ShortName ?? result;
Upvotes: 1