Add separator to string at every N characters?

后端 未结 13 2262
半阙折子戏
半阙折子戏 2020-11-27 13:20

I have a string which contains binary digits. How to separate string after each 8 digit?

Suppose the string is:

string x = \"111111110000000011111111         


        
13条回答
  •  眼角桃花
    2020-11-27 13:39

    If I understand your last requirement correctly (it's not clear to me if you need the intermediate comma-delimited string or not), you could do this:

    var enumerable = "111111110000000011111111000000001111111100000000".Batch(8).Reverse();
    

    By utilizing morelinq.

提交回复
热议问题