S
shapper
Hello,
I have the following classes:
public class OptionPaper {
public Option Option { get; set; }
}
public class Option {
public Guid OptionID { get; set; }
public string Answer { get; set; }
}
I need to create a List<OptionPaper> and fill each OptionPaper >
Option.Name = Value from OptionsCSV.
OptionsCSV is a string that holds the Answers in CSV format:
OptionsCSV = "Answer 1, Answer 2, ..."
I have the following but I am having troubles in making this work:
List<OptionPaper>.Options = paper.OptionsCSV.Split(new char[]
{ ',' },
StringSplitOptions.RemoveEmptyEntries).
Select(a =>
new Option {
OptionID =
Guid.NewGuid(),
Answer =
a.Trim()
}).ToList();
I get the following error:
Cannot implicitly convert type
'System.Collections.Generic.List<Option>' to
'System.Collections.Generic.List<OptionPaper>'
How can I make this work?
Thanks,
Miguel
I have the following classes:
public class OptionPaper {
public Option Option { get; set; }
}
public class Option {
public Guid OptionID { get; set; }
public string Answer { get; set; }
}
I need to create a List<OptionPaper> and fill each OptionPaper >
Option.Name = Value from OptionsCSV.
OptionsCSV is a string that holds the Answers in CSV format:
OptionsCSV = "Answer 1, Answer 2, ..."
I have the following but I am having troubles in making this work:
List<OptionPaper>.Options = paper.OptionsCSV.Split(new char[]
{ ',' },
StringSplitOptions.RemoveEmptyEntries).
Select(a =>
new Option {
OptionID =
Guid.NewGuid(),
Answer =
a.Trim()
}).ToList();
I get the following error:
Cannot implicitly convert type
'System.Collections.Generic.List<Option>' to
'System.Collections.Generic.List<OptionPaper>'
How can I make this work?
Thanks,
Miguel