Hello,
I have the following class ( Level is just a simple enumeration ):
public class Theme {
public Subject Subject { get; set; }
public List<LevelLevel s { get; set; }
public string Note { get; set; }
}
And MyThemes is a List<Theme>
I am filling "public string[] Themes" from a form and getting:
Themes[0] = Economy|Base,Su perior|Note 1
Themes[1] = Math|Base|Note 2
Now I need to fill MyThemes with these values:
for (int i = 0; i < this.Themes.Len gth; i++) {
this.Themes = this.Themes[i].Split(new char[] { '|' },
StringSplitOpti ons.RemoveEmpty Entries).Select (t =new Theme { Subject
= ???, Levels = ???, Note = ??? }).ToList();
}
I am a little bit confused about this.
For each Theme, Theme[i] I split it using "|" and then:
- First value is Subject
- Second value are the Levels in a CSV format (needs to be converted
to a list)
- Third value is the note
Can't I integrate Linq and Split to get this instead of using more
loops?
Thanks,
Miguel
I have the following class ( Level is just a simple enumeration ):
public class Theme {
public Subject Subject { get; set; }
public List<LevelLevel s { get; set; }
public string Note { get; set; }
}
And MyThemes is a List<Theme>
I am filling "public string[] Themes" from a form and getting:
Themes[0] = Economy|Base,Su perior|Note 1
Themes[1] = Math|Base|Note 2
Now I need to fill MyThemes with these values:
for (int i = 0; i < this.Themes.Len gth; i++) {
this.Themes = this.Themes[i].Split(new char[] { '|' },
StringSplitOpti ons.RemoveEmpty Entries).Select (t =new Theme { Subject
= ???, Levels = ???, Note = ??? }).ToList();
}
I am a little bit confused about this.
For each Theme, Theme[i] I split it using "|" and then:
- First value is Subject
- Second value are the Levels in a CSV format (needs to be converted
to a list)
- Third value is the note
Can't I integrate Linq and Split to get this instead of using more
loops?
Thanks,
Miguel
Comment