locked
Unsigned 64 bit number to string RRS feed

  • Question

  • User357616875 posted

    Why does this not work ?

    dim facilities as Uint64        
    Dim b As String = (Convert.ToString(facilities, 2))
    b = StrReverse(b.PadLeft(64, "0"))


    I get "tostring cant be called without a narrowing conversion"

    Any ideas ?

    Any help would be great

    Graham Mattingley

    Saturday, April 17, 2010 8:02 AM

All replies

  • User-1360095595 posted

    I don't see a Convert.ToString() method that take (UInt64, Int32).  There's one of (Int64, Int32).

    Edit: refer - http://msdn.microsoft.com/en-us/library/system.convert.tostring(VS.90).aspx

    Saturday, April 17, 2010 8:13 AM
  • User1671336505 posted

    Hi,

    Dim b As String = (Convert.ToString(facilities, 2))   
     

    Why do you have this 2 as a parameter in your convert statement?

    Is it not enough, if you simply say,

    Convert.ToString(facilities) ?

    Cheers,

    Sangeetha

     

    Saturday, April 17, 2010 8:17 AM
  • User-1360095595 posted

    Hi,

    Dim b As String = (Convert.ToString(facilities, 2))   
     

    Why do you have this 2 as a parameter in your convert statement?

    Is it not enough, if you simply say,

    Convert.ToString(facilities) ? 

     

    If you follow the link I provided, you'll learn that the second parameter specifies the base.  So it looks like he's trying to represent the number in binary.

    Saturday, April 17, 2010 2:46 PM
  • User357616875 posted

    Thanks for all the replys, I would not get it to work, so I split the number accross two varables.

    What I was doing was building a hotel system, using the binary value as on off switches for the facilities, and I have 64 options for the hotel facilities.



    Sunday, April 18, 2010 2:24 PM