How do I get the color from a hexadecimal color code using .NET?

前端 未结 16 798
不思量自难忘°
不思量自难忘° 2020-11-22 06:45

How can I get a color from a hexadecimal color code (e.g. #FFDFD991)?

I am reading a file and am getting a hexadecimal color code. I need to create the

16条回答
  •  鱼传尺愫
    2020-11-22 07:11

    The three variants below give exactly the same color. The last one has the benefit of being highlighted in the Visual Studio 2010 IDE (maybe it's ReSharper that's doing it) with proper color.

    var cc1 = System.Drawing.ColorTranslator.FromHtml("#479DEE");
    
    var cc2 = System.Drawing.Color.FromArgb(0x479DEE);
    
    var cc3 = System.Drawing.Color.FromArgb(0x47, 0x9D, 0xEE);
    

提交回复
热议问题