I have a list and data as follows.
public class Test
{
public int Id {get;set;}
public string Name {get;set;}
public string Quality {get;set;}
}
Test test = new Test();
//db call to get test data
//test = [{1,'ABC','Good'},{2,'GEF','Bad'}]
I have to modify the list such that Name should be only the first 2 characters and Quality should be the first letter.
Expected Output:
//test = [{1,'A','G'},{2,'GE','B'}]
I tried to achieve with Linq foreach as follows. But I am not sure to write conditional statements inside forloop within Linq which resulted in error.
test.ForEach(x=> return x.Take(1))
ToStringfunction insideTestclass, In that function you could substring all fields as u wish, and return a string.