I have varying string values that I want to add to a key inside a dictionary.
What is the correct answer(key)
AnswerA(value)
AnswerB(value)
AnswerC(value)
I am doing this by using the split on a string(which happens in a loop).
string[] arr = l.ContentDescription.Split('|').ToArray();
Dictionary<string, List<string>> questions = new Dictionary<string, List<string>>();
for (int i = 0; i < arr.Length - 1; i++)
{
var arrB = arr[i + 1].Split('*').ToArray();
//all theanswers should now be added to the list
questions.Add(arrB[0], new List<string>() { });
}
arr looks something like this
Choose the correct answer and submit|What is the correct answer*AnswerA*AnswerB*AnswerC
What is the best way of adding these answer values if they vary in length
questions.Add(arrB[0], arrB.Skip(1).ToList() );?