I have a c# application which displays the names of assessments and the zone which they are performed upon, separated by a comma and a space. For instance:
- assessment1, Firewall
- mom's assessment, LAN
When the user selects on of these assessments, I need to separate the assessment name from the zone name. I also need to replace any single quotes in the string by two single quotes so I can query my database without issues (this i cannot change, it has to be done because no SQLiteParameters are used in the function that queries my database).
This is how I do this currently (note that _view.SelectedAssessment is the entire string of both the assessment name and zone):
string zone = _view.SelectedAssessment.Substring(_view.SelectedAssessment.IndexOf(", ") + 2);
string assessmentName = _view.SelectedAssessment.Substring(0, _view.SelectedAssessment.Length - zone.Length - 2);
Is there a better way to do this? Any improvements?