public class ColorConverter
{
public static string GetHexFromRGB(string R, string G, string B)
{
string result = "";
result += GetHex(Math.Floor(int.Parse(R) / 16)) + GetHex(Math.Floor(int.Parse(R) / 16))
+ GetHex(Math.Floor(int.Parse(G) / 16)) + GetHex(int.Parse(G) % 16)
+ GetHex(Math.Floor(int.Parse(B) / 16)) + GetHex(int.Parse(B) % 16);
return result;
}
private static string GetHex(double Dec)
{
string Value = "";
char c = 'A';
if (Dec >= 10 && Dec <= 15)
{
c += (char)(Dec - 10);
Value += c;
}
else Value = "" + Dec;
return Value;
}
}
{
public static string GetHexFromRGB(string R, string G, string B)
{
string result = "";
result += GetHex(Math.Floor(int.Parse(R) / 16)) + GetHex(Math.Floor(int.Parse(R) / 16))
+ GetHex(Math.Floor(int.Parse(G) / 16)) + GetHex(int.Parse(G) % 16)
+ GetHex(Math.Floor(int.Parse(B) / 16)) + GetHex(int.Parse(B) % 16);
return result;
}
private static string GetHex(double Dec)
{
string Value = "";
char c = 'A';
if (Dec >= 10 && Dec <= 15)
{
c += (char)(Dec - 10);
Value += c;
}
else Value = "" + Dec;
return Value;
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货