cant convert double to int, cant convert double to string, cant convert double to double
|
The exact error message would probably be helpful. It doesn't sound like you're giving the error message verbatim. If I had to guess, I'd assume Ps was an array of doubles? It sounds like you have an array of doubles, but you're trying to convert that into a double, or vice versa (trying to convert a double to an array of doubles).
I'm not familiar with razor C#, so my help may be kinda useless, so I might just call it quits, hopefully someone else can help (but note that since this is a C++ forum, might not be likely).
Anyway, few last questions:
ToString("c") is trying to format the double as a currency value, correct? Perhaps the value is too small, and it's rounding the value to 0?
What type is Ps? What is the actual value of Ps[x] before you call Ps[x].ToString("c")?
ex, the following would display 0.00 because it's too small of an amount.
1 2 3 4 5 6 7 8
|
public class Program
{
public static void Main(string[] args)
{
double v = 0.000125;
Console.WriteLine(v.ToString("C"));
}
}
|
The following, however, will fail because it can't convert an array of doubles to formatted string
1 2 3 4 5 6 7 8
|
public static void Main(string[] args)
{
//Your code goes here
double v = 0.000125;
double[] varr = {0.001, 0.02, 0.5, 1.5};
Console.WriteLine(v.ToString("C"));
Console.WriteLine(varr.ToString("C")); // fails
}
|
Note how v is a double, but varr is an array of doubles.
(I'm not sure if that's what your problem is, just guessing).