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);
原文地址:https://www.cnblogs.com/lonelyxmas/p/9589374.html
时间: 2024-10-05 01:43:50