将字符串转换成System.Drawing.Color类型的方法
程序员文章站
2023-12-18 18:24:16
1、color.fromargb(120,243,244,247) 先将f3,f4,f7转化为十进制数,再调用以上方法。2、把f3 f4 f7转成10进制 &n...
1、color.fromargb(120,243,244,247)
先将f3,f4,f7转化为十进制数,再调用以上方法。
2、把f3 f4 f7转成10进制
然后用 color.fromargb
3、color yourcolor = color.fromname("#f3f4f7");
4、比较笨一点的办法:
string a="#f3f4f7";
new system.drawing.color.fromargb(
system.int8.parse(a.substring(1,2),system.globalization.numberstyles.allowhexspecifier);
system.int8.parse(a.substring(3,2),system.globalization.numberstyles.allowhexspecifier);
system.int8.parse(a.substring(5,2),system.globalization.numberstyles.allowhexspecifier);
);
5、color color =color.fromargb(0xf3,0xf4,0xf7);
6、public forecolor as system.drawing.color = colortranslator.fromhtml("#f3f4f7")
7、system.drawing.colorconverter cc=new system.drawing.colorconverter();
return (system.drawing.color)cc.convertfromstring(shex);
先将f3,f4,f7转化为十进制数,再调用以上方法。
2、把f3 f4 f7转成10进制
然后用 color.fromargb
3、color yourcolor = color.fromname("#f3f4f7");
4、比较笨一点的办法:
string a="#f3f4f7";
new system.drawing.color.fromargb(
system.int8.parse(a.substring(1,2),system.globalization.numberstyles.allowhexspecifier);
system.int8.parse(a.substring(3,2),system.globalization.numberstyles.allowhexspecifier);
system.int8.parse(a.substring(5,2),system.globalization.numberstyles.allowhexspecifier);
);
5、color color =color.fromargb(0xf3,0xf4,0xf7);
6、public forecolor as system.drawing.color = colortranslator.fromhtml("#f3f4f7")
7、system.drawing.colorconverter cc=new system.drawing.colorconverter();
return (system.drawing.color)cc.convertfromstring(shex);