Is there a way to find part of a string in an enum like this:
Status.Find("InStock");
public enum Status
{
Unknown,
InStock,
InStockReserved,
Taken,
TakenReserved,
Spent,
}
And then get the respective int values. Like in the Find command for a List:
list.Find(x => x.Name.Contains("InStock")));
Sounds like you want something like:
var integers = Enum.GetValues(typeof(Status))
.Cast<Status>()
.Where(status => status.ToString().Contains("InStock"))
.Select(status => (int) status);
See more on this question at Stackoverflow