I have an object like that
public class MyModel
{
public int Key { get; set; }
public string Value { get; set; }
}
And I have model like List<MyModel>
model[0]=new MyModel(){Key = 1,Value ="Something"};
model[1]=new MyModel(){Key = 3,Value ="Something else"};
I want this output :
1. Value is = Something //there is \n here
3. Value is = Something else
So the seperator is \n and while string.join(" \n ", ? ) what should I do?
Is that possible or not? I did it like that but I want to learn can I string.join() do that:
var newArray = model.Select(x => ((x.Key)+". Value is ="+x.Value));
string.join(" \n ",newArray );
Sorry for my bad english...
string.Join()notstring.join(). And you should remove the space before"\n"in the separator. But other than that, your code seems to deliver your desired result.newArrayis poorly named: the result of Select is an IEnumerable, not an array