I am in C# MVC (.NET) and have a form where I have input with @html.TextAreaFor stored as a string I am assuming that the data from this text box will store as a string, but what I am wondering is how will the string look, in terms of "/n" elements, will the string delimit new line markers?
Ideally, I need to parse the textbox line-by-line, where the string on each line becomes an element of a List For example, if we have in the textbox
item1
item2
item3
Then when I submit the form, the model that I specified will be loaded with the string form the textbox, and using that string we will load up our List (somewhere else, in a different model..)with item1, item2, and item3.
List<string> list = new List<string>(); string[] lines = textareamodel.Split(new string[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries), then useforeach (string line in lines) { list.Add(line); }. I can write as answer if this trick works.List<string> list = textareamodel.Split(new string[] {Environment.NewLine}, StringSplitOptions.RemoveEmptyEntries).ToList().ToList()asList<string>, but let's see if OP solves his problem first.