String Operation using Linq

You might need to use GroupBy:

string str = "[email protected]@[";

var groups = str.Select((v, i) => new { Group = i % 3, Ch = v })
                .GroupBy(item => item.Group == 1)
                .Select(group => string.Join("", group.Select(item => item.Ch)))
                .ToList();

// groups: ["GPCSC[", "[email protected]@"]

Browse More Popular Posts

Leave a Comment