score:1

{
    "1,3",
    "4,6",
    "7,9",
    "10,12"
};

score:1

        //----------------linq.----------------------
        
        //data source 
        var source = new list<string> { "1,2,3", "4,5,6", "7,8,9", "10,11,12" };
        //var sourcetest = new list<string> { "11,45,6,5,", "2,3,4,5,6", "1,7,40,30", "10,20,30,40,50" };
        //var sourcetest2 = new list<string> { "15,12,11,45,6,5,", "1,2,3,4,5,6", "1,7,9,40,30", "60,20,70,80,90,100" };
        //query creation
        var querylambda = source.select(item => new
                                    {
                                        firstitem = item.split(',').firstordefault(),
                                        thirditem = item.split(',').skip(2).firstordefault()
                                    }).tolist();
        var query = (from items in source
                     select new
                     {
                         firstitem = items.split(',').firstordefault(),
                         thirditem = items.split(',').skip(2).firstordefault()
                     }).tolist();

        //query execution
        querylambda.foreach(item => { console.writeline(string.join(",", new string[] { item.firstitem, item.thirditem })); });
        console.writeline();
        query.foreach(item => { console.writeline(string.join(",", new string[] { item.firstitem, item.thirditem })); });
        console.readline();

score:2

ienumerable<tuple<string, string>> parsed = list.select(
    s => (s.split(',')[0], s.split(',')[2]));

Related Query

More Query from same tag