自己寫了個TypeConverter把陣列轉換成string
不使用TypeConverter效果

使用TypeConverter效果

我只想把Double[] Array變成字串,可是轉換后,展開的內容也變了,有大佬知道怎么弄嗎
private double[] exposeTime = new double[] { 1, 2, 4 };
[Browsable(true)]
[ReadOnly(false)]
[Category("相機引數")]
[DisplayName("曝光時間")]
[XmlElement("曝光時間")]
[TypeConverter(typeof(ArrayConverter))]
public double[] ExposeTime
{
get
{
return exposeTime;
}
set
{
exposeTime = value;
}
}
public class ArrayConverter : ExpandableObjectConverter
{
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, System.Type destinationType)
{
if (destinationType == typeof(System.String) && value is double[])
{
var v = value as double[] ;
string s=string.Empty;
foreach(var a in v)
{
s += a.ToString() + ",";
}
return s.TrimEnd(',');
}
return base.ConvertTo(context, culture, value, destinationType);
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/172939.html
標籤:C#
上一篇:跪拜全堆疊或前端和后端老師
