Usando C# Estaba intentando desarrollar los siguientes dos. La forma en que lo estoy haciendo puede tener algún problema y necesito su amable consejo. Además, no sé si hay algún método existente para hacer lo mismo.Convertir System.Drawing.Color a RGB y Hex Value
private static String HexConverter(System.Drawing.Color c)
{
String rtn = String.Empty;
try
{
rtn = "#" + c.R.ToString("X2") + c.G.ToString("X2") + c.B.ToString("X2");
}
catch (Exception ex)
{
//doing nothing
}
return rtn;
}
private static String RGBConverter(System.Drawing.Color c)
{
String rtn = String.Empty;
try
{
rtn = "RGB(" + c.R.ToString() + "," + c.G.ToString() + "," + c.B.ToString() + ")";
}
catch (Exception ex)
{
//doing nothing
}
return rtn;
}
Thanks.
@Rod https://stackoverflow.com/questions/20750062/what- is-meaning-of-tostringx2 – samgak