I have a class like this:
public class MyClass
{
public int Line;
public string Name1;
public string Name2;
}
and a collection of MyClass objects:
List<MyClass> myObjs = myService.GetObjects();
where myObjs
has 2 elements:
[0]: Line: 1, Name1: "Test1", Name2: "Test2"
[1]: Line: 2, Name1: "Test3", Name2: "Test4"
I'd like to get every object with their properties concatenated in a string like:
"1,Test1,Test2;2,Test3,Test4"
I tried string.Join(",", myObjs.Select(x => x.Line));
but that only gives me a list of all the Line values. I need everything in the object.