1.string和Color的转换:

//string转Color
(Color)ColorConverter.ConvertFromString((string)str);
//Color转string
((Color)value).ToString();

2.string和Brush的转换:

//string转Brush 
Brush color = new SolidColorBrush((Color)ColorConverter.ConvertFromString((string)str));
//Brush转string
((Brush)value).ToString();

3.string和byte[]的转换:

//string转byte[]
System.Text.UnicodeEncoding converter = new System.Text.UnicodeEncoding();
byte[] stringBytes = converter.GetBytes(inputString);
//byte[]转string
System.Text.UnicodeEncoding converter = new System.Text.UnicodeEncoding();
string outputString = converter.GetString(stringByte);
 

相关文章:

  • 2021-11-25
  • 2022-02-15
  • 2021-10-31
  • 2022-12-23
  • 2022-12-23
  • 2021-08-23
  • 2022-01-26
  • 2021-06-24
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-21
  • 2021-10-11
  • 2021-06-27
  • 2021-10-03
  • 2022-12-23
相关资源
相似解决方案