Hello, I'm just starting to dive into the world of development, I wanted to ask for advice on how to improve the following code:
JobKind jobKind = 0; foreach (JobKind value in Enum.GetValues(typeof(JobKind))) { var enumIntValue = (int)value; if (model.JobKinds.Contains(enumIntValue.ToString())) { var checkedSymbol = char.Parse(enumIntValue.ToString()); if ((model.JobKinds.LastIndexOf(checkedSymbol) - model.JobKinds.IndexOf(checkedSymbol)) == 0) jobKind = jobKind | value; } } JobKind is an enumeration with the [Flags] attribute. At the entrance is a model that contains a string field - types of specialties. There is a listing. For convenience, you can specify the numbers of sets of specialties (for example, 2,4,5 ). The numbers are equal to the value of the fields in the listing. This code forms a bit field and enumerations from a string. I didn’t find how to convert a string like 2,4,5 into a listing in a more elegant way, so I would like to ask your advice on how to improve the readability of the code, etc.
model.JobKinds? and an example of the value of this field - Grundy2? - Grundy