devxlogo

July 4, 2019

Convert Hex to RGB in C#

The .NET System.Globalizaton’s NumberStyles has a parameter called AllowHexSpecifier that helps us to replace a hexString with RGB color. public static Color HexToColor(string hexString){ //replace # occurences if (hexString.IndexOf(‘#’) !=