c# - Array of fixed-length BitArrays -
i'm in trouble bitarray
.
the goal simulate stack of 8 80bit bitarrays, numbered 0 7.
i need able access them index, , think simple array enough me.
when initialising bitarray
object, need specify number of bits contain, gives me
bitarray test = new bitarray(80);
how can array of it, knowing need specify length value?
i've tried several things,
bitarray[] stack = new bitarray(80)[];
but error when trying give length...
any thoughts?
thanks in advance
unfortunately, framework doesn't appear have "canonical" array-initialization pattern, far know.
one way, using linq, be:
var stack = enumerable.range(0, 8) .select(i => new bitarray(80)) .toarray();
or:
var stack = enumerable.repeat<func<bitarray>>( () => new bitarray(80), 8) .select(f => f()) .toarray();
alternatively,
bitarray[] stack = new bitarray[8]; for(int = 0; < stack.length; i++) stack[i] = new bitarray(80);
Comments
Post a Comment