S
shapper
Hello,
I have the following class ( Level is just a simple enumeration ):
public class Theme {
public Subject Subject { get; set; }
public List<Level> Levels { 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,Superior|Note 1
Themes[1] = Math|Base|Note 2
Now I need to fill MyThemes with these values:
for (int i = 0; i < this.Themes.Length; i++) {
this.Themes = this.Themes.Split(new char[] { '|' },
StringSplitOptions.RemoveEmptyEntries).Select(t => new Theme { Subject
= ???, Levels = ???, Note = ??? }).ToList();
}
I am a little bit confused about this.
For each Theme, Theme 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<Level> Levels { 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,Superior|Note 1
Themes[1] = Math|Base|Note 2
Now I need to fill MyThemes with these values:
for (int i = 0; i < this.Themes.Length; i++) {
this.Themes = this.Themes.Split(new char[] { '|' },
StringSplitOptions.RemoveEmptyEntries).Select(t => new Theme { Subject
= ???, Levels = ???, Note = ??? }).ToList();
}
I am a little bit confused about this.
For each Theme, Theme 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