String to long

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • willemr
    New Member
    • May 2010
    • 9

    String to long

    Hi guys,


    I have another problem with the RFID types.

    I have a program that delivers me the RFID in a string

    Code:
    string RFID = 003000d4;
    But I have to get it in a long called RFIDlong, it tried several thing I found on the net.

    Code:
    RFIDlong = convert.toInt64(RFID);
    RFIDlong = long.parse(RFID);
    And some other, but nothin has worked.


    Can anyone help please?
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    Did you tried

    Code:
    Convert.ToInt64(RFID,16);
    Regards
    Dheeraj Joshi

    Comment

    • willemr
      New Member
      • May 2010
      • 9

      #3
      Yeah indeed, now it works.

      Thanks man

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        For the record, this also works:
        Code:
        string num = "003000d4";
        long l = long.Parse(num, System.Globalization.NumberStyles.HexNumber);
        The issue seems to be the fact that the number is HEX. If it were not, then either of the things you tried first would work.

        Comment

        • tlhintoq
          Recognized Expert Specialist
          • Mar 2008
          • 3532

          #5
          I showed you how to properly format a hex number to become an int in the other thread you started on this problem. That is why we ask you to not start multiple threads on the same problem, because it divides efforts to help you. Look at the code in the first thread.

          Comment

          Working...