From
int BinaryTable = new int[] { 1101 };
To
int BinaryTable = new int[] { 1,1,0,1 };
Don't know how to change it right.
You could do it this way:
var bits = BinaryTable.Select(b =>
b.ToString().
Select(r => r == '0' ? 0 : 1))
.SelectMany(x => x);
This works if you want to get from
[1101,11] → [1,1,0,1,1,1]
. It is not really clear what exact do you want. And this solution doesn't check that your input really contains only 1 and 0 digits, since it is integer it could theoretically contain every number.
Quick and dirty LINQ:
Or since
13 == 1101 binary
:In case you want convert one array into another array, use
SelectMany
instead ofSelect
:Or int[] source = new int[] {13};