How to split a string in chunks of eight chars?
c#, linq
Solution
Try this:
IEnumerable<string> groups = Enumerable.Range(0, binaryString.Length / 8)
.Select(i => binaryString.Substring(i * 8, 8));
Problem
I have following binary string ``` string binaryString = "110011100110011011001110011001101100111001100110110011100110011011001110001001100110011011001110"; ``` Now I want to split the above string into group of 8 characters. eg. ``` 11001110 11001110 11001110 11001110 11001110 11001110 ``` I tried following code but not getting expected result ``` var binary = binaryString.Where((x, y) => y % 8 == 0).ToList(); ```