none
How can I convert 1118 dec to 045E hex ? RRS feed

Answers

  • public string ToHex ( string input)
    {
       //Assuming Int32 here...
       if (Int32.TryParse(input, out var result))
          return result.ToString("X4");
    
       return null;
    }
    Convert to int then use built in support for generating hex values.

    Michael Taylor http://www.michaeltaylorp3.net

    • Proposed as answer by cheong00Editor Thursday, December 12, 2019 1:12 AM
    • Marked as answer by cheong00Editor Tuesday, January 14, 2020 3:29 AM
    Wednesday, December 11, 2019 7:06 PM
    Moderator

All replies

  • public string ToHex ( string input)
    {
       //Assuming Int32 here...
       if (Int32.TryParse(input, out var result))
          return result.ToString("X4");
    
       return null;
    }
    Convert to int then use built in support for generating hex values.

    Michael Taylor http://www.michaeltaylorp3.net

    • Proposed as answer by cheong00Editor Thursday, December 12, 2019 1:12 AM
    • Marked as answer by cheong00Editor Tuesday, January 14, 2020 3:29 AM
    Wednesday, December 11, 2019 7:06 PM
    Moderator
  • Hi Peu,

    Has your issue been resolved?

    If so, please click "Mark as answer" to the appropriate answer, so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, January 2, 2020 6:59 AM