Array containing only 0 and 1 values

I need an array which will only contain the values 0 and 1. Will bool[] be good enough for me? Or is there something lighter weight?

EDIT:

I dont have memory constraints but that array is made and passes online All The Time with big files passes concurrently with that array. I want the maximun optimization so the big files wont be delayed

Answers


A bool is probably not the best way to do it. Depends how many numbers you have got.

It is important to realise that even though a bool is a single bit, it requires a full byte in memory.

A BitArray on the other hand takes care of this for you and is more space efficient, although ever so slightly less time efficient. http://msdn.microsoft.com/en-us/library/system.collections.bitarray.aspx

Depends on your constraints, if it is not for a constrained environment a bool array will work just fine.


Need Your Help

Custom Controls with Blend

silverlight silverlight-2.0

I'm building custom control for my Silverlight 2 app. It's in one SL class project, and it contains two files:

parallel asynchronous jQuery-AJAX-Requests blocking each other

javascript jquery ajax asynchronous

I use jQuery to do some asynchronous background data fetching. I stumbled upon the problem, that more than one parallel request to the same URL does not finish, until the first request handler is

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.