Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do you convert a double to a double[]?
Posted

You don't. If you want an array of doubles, you can try this.
C#
double value1 = 0.0;
double[] valueArray = new double[1];
valueArray[0] = value1;

or
C#
double value1 = 0.0;
double[] valueArray = new double[]{value1};
 
Share this answer
 
v2
Comments
Espen Harlinn 28-Dec-11 13:44pm    
Right as usual
fjdiewornncalwe 28-Dec-11 13:54pm    
Thanks, Espen
#realJSOP 28-Dec-11 13:52pm    
5 - Proposed as answer
fjdiewornncalwe 28-Dec-11 13:54pm    
Thanks John
Rajesh Anuhya 28-Dec-11 22:58pm    
Good answer, gave my +5
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)?
 
Share this answer
 
Comments
Espen Harlinn 28-Dec-11 13:44pm    
Right :)
Or in general
C#
public static T[] ToArray<T>(T t)
        {            
            return new T[] { t };
        }


C#
public static Array ToArray(Object o)
        {
            Array result = Array.CreateInstance(o.GetType(), 1);
            result.SetValue(o, 0);
            return result;
        }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900