Array of fixed-length BitArrays

I'm in trouble with a BitArray.

The goal is to simulate a stack of 8 80bit BitArrays, numbered from 0 to 7.

I just need to be able to access them by index, and so I think a simple array will be enough for me.

When initialising a BitArray object, I need to specify the number of bits it will contain, which gives me

BitArray test = new BitArray(80);

How can I do an Array of it, knowing I need to specify the length value?

I've tried several things, like

BitArray[] stack = new BitArray(80)[];

but I always get an error when trying to give it the length...

Any thoughts?

Thanks in advance


Unfortunately, the framework doesn't appear to have a "canonical" array-initialization pattern, as far as I know.

One way, using LINQ, would be:

var stack = Enumerable.Range(0, 8)
                      .Select(i => new BitArray(80))


var stack = Enumerable.Repeat<Func<BitArray>>( () => new BitArray(80), 8)
                      .Select(f => f())


BitArray[] stack = new BitArray[8];

for(int i = 0; i < stack.Length; i++)
   stack[i] = new BitArray(80);

Need Your Help

Is there any way to build a function from NSString?

objective-c nsstring selector

Lets say I download some text from webservice contain objective-c code, is there any way to make it selector?

SubSonic: MaxLength of TableColumn (exceeding)

c# mysql subsonic subsonic2.2

So, we're using SubSonic as our DAL/ORM for one of our projects. Everything has been running smoothly (the database already existed, so we used SubSonic on top of it), however, on occasion we'll ru...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.