what is the difference between bitvector32 and bitarray

Discussion in 'C#' started by urvinit, May 23, 2010.

  1. #1
    Hi,
    I have some questions regarding bitvector32 and bitarray.

    1.what is the difference between bitvector32 and bitarray?

    2.what is the difference between bitvector32(1) and bitvector32(-1)?

    3.why the performance of bitvector32 is greater than the bitarray?


    Regards
    Vinit
     
    urvinit, May 23, 2010 IP
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    According to the MSDN:
    'BitVector32 is more efficient than BitArray for Boolean values and small
    integers that are used internally. A BitArray can grow indefinitely as
    needed, but it has the memory and performance overhead that a class instance
    requires. In contrast, a BitVector32 uses only 32 bits.'
     
    ccoonen, May 25, 2010 IP
  3. aeroz1

    aeroz1 Active Member

    Messages:
    492
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #3
    'BitVector32 is more efficient than BitArray for Boolean values and small
    integers that are used internally. A BitArray can grow indefinitely as
    needed, but it has the memory and performance overhead that a class instance
    requires. In contrast, a BitVector32 uses only 32 bits.'
     
    aeroz1, Jun 7, 2010 IP
  4. srmkymca

    srmkymca Guest

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    BitVector32 is a struct and consumes only 4 bytes. BitArray is a class that has overheads associated with it and is therefore less efficient - BitArray will need at least 8 bytes before you've even added any objects to it as it lives on the heap.
     
    srmkymca, Jun 26, 2010 IP