Converting hex to int and back again in C#

Converting hex to int and back again in C#

No, nothing startling or new, but something I forget every time. So, to save myself searching for it again, here is how to convert a hex value to an integer...

Convert.ToInt32("ff", 16)

...and to convert an int to hex, you simply do...

255.ToString("X")

Maybe now I've written a blog post about these, I might remember them next time.

Ha ha, fat chance!

Comments

No approved comments yet.

Leave a comment