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('#') != -1) hexString = hexString.Replace("#", ""); int r,g,b = 0; r = int.Parse(hexString.Substring(0, 2), NumberStyles.AllowHexSpecifier); g = int.Parse(hexString.Substring(2, 2), NumberStyles.AllowHexSpecifier); b = int.Parse(hexString.Substring(4, 2), NumberStyles.AllowHexSpecifier); return Color.FromArgb(r, g, b);}
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.





















