Manipulating BITS in C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • HTB
    New Member
    • Aug 2007
    • 13

    Manipulating BITS in C#

    Hi,

    Now, if we have a String we can manipulate its basic components
    (Char). How about a Byte, are we able to manipulate its (Bits) one
    by one.

    I found a class Bit in Java, how about C#.


    What do you think, guys !?
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    There are no bits in byte ;).

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      There is an object called a BitArray. I have only found a few uses for it though.

      (Also you can have an array of boolean type, but there is no native method for them to turn into a byte I don't think)

      Comment

      • HTB
        New Member
        • Aug 2007
        • 13

        #4
        kenobewan,

        :) you're right. I thought the data type Byte is the normal byte which
        consists of 8 bits. anyways...

        Comment

        • HTB
          New Member
          • Aug 2007
          • 13

          #5
          So, can we get a byte via read() and convert it to BitArray and then
          we manipulate the array one by one !!!!?

          Comment

          • TRScheel
            Recognized Expert Contributor
            • Apr 2007
            • 638

            #6
            Originally posted by HTB
            So, can we get a byte via read() and convert it to BitArray and then
            we manipulate the array one by one !!!!?
            yes but a bitarray pretends they are all bools, FYI

            Comment

            • Plater
              Recognized Expert Expert
              • Apr 2007
              • 7872

              #7
              What about a union of a bool[8] and a Byte ?

              Comment

              • TRScheel
                Recognized Expert Contributor
                • Apr 2007
                • 638

                #8
                Originally posted by Plater
                What about a union of a bool[8] and a Byte ?
                I now pronounce you Pieces and A Whole

                Comment

                • Plater
                  Recognized Expert Expert
                  • Apr 2007
                  • 7872

                  #9
                  Well scratch that.
                  There are no Unions in C#.
                  You can mimic them, but only down to the byte level, not the bit level

                  Comment

                  Working...