将double转换为double [] [英] Conversion of double to double[]
本文介绍了将double转换为double []的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将double转换为double []?
How do you convert a double to a double[]?
推荐答案
您不知道.如果您想要一个双精度数组,可以尝试一下.
You don''t. If you want an array of doubles, you can try this.
double value1 = 0.0;
double[] valueArray = new double[1];
valueArray[0] = value1;
或
or
double value1 = 0.0;
double[] valueArray = new double[]{value1};
通常来说,没有这种转换.您为什么要提出要求(即确切地知道您的要求,也许我们可以为您提供解决方案?)?
Generally speaking there is NOT such a conversion. Why are you asking for (i.e. knowing exactly your requirements maybe we can provide you a work around)?
,或者通常是
public static T[] ToArray<T>(T t)
{
return new T[] { t };
}
public static Array ToArray(Object o)
{
Array result = Array.CreateInstance(o.GetType(), 1);
result.SetValue(o, 0);
return result;
}
这篇关于将double转换为double []的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文