Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to parse hex values into a uint?

Tags:

c#

uint color;  bool parsedhex = uint.TryParse(TextBox1.Text, out color);  //where Text is of the form 0xFF0000 if(parsedhex)    //... 

doesn't work. What am i doing wrong?

like image 586
Cameron A. Ellis Avatar asked Sep 19 '08 01:09

Cameron A. Ellis


1 Answers

Try

Convert.ToUInt32(hex, 16)  //Using ToUInt32 not ToUInt64, as per OP comment 
like image 175
Nescio Avatar answered Oct 09 '22 14:10

Nescio