HEX Operations in C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RobLefevre
    New Member
    • Jun 2008
    • 4

    HEX Operations in C#

    I ran into this ridiculous problem while working on a checksum problem.

    I currently have a string containing the HEX values of a checksum.
    Is there any way in .net to perform AND operations on two HEX values?

    I need to AND my result with 7F.
  • RedSon
    Recognized Expert Expert
    • Jan 2007
    • 4980

    #2
    Does the bitwise "and" operator not work for you?

    Comment

    • nmsreddi
      Contributor
      • Jul 2006
      • 366

      #3
      Hello

      i too have done some thing like this , i never find direct operation on Hex values

      i am converting my complete values to binary values then i am applying my logic there .

      Hope may help you too.

      Regards
      nmsreddi

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Int.Parse() can be overloaded to accept HEX values
        (e.g. int.Parse("2A") will give you 42)
        You can typecast to a byte do your AND operations like that?

        Comment

        • RedSon
          Recognized Expert Expert
          • Jan 2007
          • 4980

          #5
          Originally posted by Plater
          Int.Parse() can be overloaded to accept HEX values
          (e.g. int.Parse("2A") will give you 42)
          You can typecast to a byte do your AND operations like that?
          You cant do?

          Code:
          int x;
          x = 0x7F & 0xA;
          In this case x would be 137 or in hex 89 or in binary 10001001?

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            Originally posted by RedSon
            You cant do?

            Code:
            int x;
            x = 0x7F & 0xA;
            In this case x would be 137 or in hex 89 or in binary 10001001?
            You can, but if you have a string like this "A3 D7 22 3E FA" you would need some sort of automated system.

            Comment

            Working...