Click here to Skip to main content
15,911,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can someone please help me

C#
double[] values = new double[73];
            for (int j = 1; j == values.Length - 1; j++)
            {
                values[j] = C158_Calc;
            }
            B162_Calc = Financial.IRR(ref values, 0.1);


I receive an error "Arguments are not valid."
Posted
Updated 1-Jun-10 2:01am
v2

When you start writing IRR, the intellisense should show you the available overloads for that method.

Do you have one there that accepts the types you supply (array of double by reference and double (presumably) ???
 
Share this answer
 
The function definition for IRR is (ref double[] ArrayValue, double guess)

All my values are double.
 
Share this answer
 
Comments
Johnny J. 1-Jun-10 8:17am    
You should have posted this as a comment to my answer instead of clicking "Add answer", but never mind now. It looks ok to me, have you tested that your array is not null/empty?
jellybeannn 1-Jun-10 8:27am    
Ok the aray is returning 0,

How can I then add the value to the array, I'm creating a DataSet with 270 months so I have a for loop for this, and I calculated C158_Calc for each month(these values are correct), I can I put each month's C158_Calc in the array. BTW this is the 6year IIR so only up to Month 73.

double[] values = new double[73];

DataTable dt = new DataTable("Details");
DataSet ds = new DataSet();
ds.Tables.Add(dt);

for (int i = 1; i <= 240; i++)
{
dt.Columns.Add("Month" + i, typeof(string));
}

dt.Columns.Add("End", typeof(string));

double C152_Calc = C150_Calc + C151_Calc;

double BW154_Calc = 0.0;
if (i == 72)
BW154_Calc = (C152_Calc * 12 / G169_In) * 100;
if (i == 240)
BW154_Calc = (C152_Calc * 12 / G170_In) * 100;

num3 += BW154_Calc;

// calculate 6 year IRR
if (i == 1)
C158_Calc = H30_Out + C152_Calc;
if (i >= 2 && i <= 72)
C158_Calc = C152_Calc;
if (i == 73)
C158_Calc = C152_Calc + num3;

// total 6 year IRR
for (int j = 1; j == values.Length - 1; j++)
{
values[j] = C158_Calc;
}

// calculate 20 year IRR
double C160_Calc = 0.0;
if (i == 1)
C160_Calc = H30_Out + C152_Calc;
else
C160_Calc = C152_Calc;

row1["Month" + i] = String.Format("{0:#,###,###,###}", C146_Calc);
row2["Month" + i] = String.Format("{0:#,###,###,###}", C148_Calc);
row3["Month" + i] = String.Format("{0:#,###,###,###}", C150_Calc);
row4["Month" + i] = String.Format("{0:#,###,###,###}", C151_Calc);
row5["Month" + i] = String.Format("{0:#,###,###,###}", C152_Calc);
row6["Month" + i] = String.Format("{0:#,###,###,###}", BW154_Calc);
row7["Month" + i] = String.Format("{0:#,###,###,###}", C158_Calc);
row8["Month" + i] = String.Format("{0:#,###,###,###}", C160_Calc);
}

B162_Calc = Financial.IRR(ref values, 0.1);
row9["Month1"] = String.Format("{0:#,###,###,###.##}", B162_Calc);
I suppose the answer to your question is in the IRR method documentation [^]:

ValueArray
Type: System.Double[]
Required. Array of Double specifying cash flow values. The array must contain at least one negative value (a payment) and one positive value (a receipt).

:)
 
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