using System.Globalization;
public static void Main()
Console.WriteLine(GetContrastingColor("fbe164"));
public static string GetContrastingColor(string hexColor)
if (hexColor.Length != 6)
throw new ArgumentException("Input hex color should be 6 digits long");
var r = int.Parse(hexColor.Substring(0, 2), NumberStyles.HexNumber);
var g = int.Parse(hexColor.Substring(2, 2), NumberStyles.HexNumber);
var b = int.Parse(hexColor.Substring(4, 2), NumberStyles.HexNumber);
return r.ToString("X2")+g.ToString("X2")+b.ToString("X2");