Posted By

jimfred on 08/10/09


Tagged

c


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

umang_nine
khouser


Represent int as hex with leading zeros


 / Published in: C#
 

URL: http://www.gamedev.net/community/forums/topic.asp?topic_id=383348

  1. Console.WriteLine("|0123456789|\n|{0,10}|", 47.ToString("X4"));
  2. // produces the output
  3. // |0123456789|
  4. // | 002F|

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: verence on August 15, 2009

Why this complicated 47.ToString("X").PadLeft(4, '0') ?

Just use

47.ToString("X4")

Posted By: jimfred on August 15, 2009

Thanks!

Posted By: misserwell on September 13, 2009

hi, submitter, could you ask the first question from verence? thanks

Posted By: misserwell on September 13, 2009

sorry ,ask --> answer

You need to login to post a comment.