wpf string to color to brush to byte[]

来源:互联网 发布:nginx 配置根目录 编辑:程序博客网 时间:2024/05/21 10:35
 color转为brush:
Brush br = new SolidColorBrush(Color.FromRgb(0,0,0)); 

 

  string转Color

(Color)ColorConverter.ConvertFromString((string)str); 

 

//Color转string 
((Color)value).ToString(); 

 

  string和Brush的转换

Brush color = newSolidColorBrush((Color)ColorConverter.ConvertFromString((string)str)); 

 
//Brush转string 
((Brush)value).ToString(); 

 

  string转byte[]

System.Text.UnicodeEncoding converter = newSystem.Text.UnicodeEncoding(); 
byte[] stringBytes = converter.GetBytes(inputString); 
  
//byte[]转string 
System.Text.UnicodeEncoding converter = newSystem.Text.UnicodeEncoding(); 
stringoutputString = converter.GetString(stringByte); 
原创粉丝点击