Why are you creating a new instance in your method, which gets thrown away at the end for the method when you return?
method is non-static, it has an instance to work with: the current instance (which is also known as
- but in this example you don't need to use it explicitly).
For example, if I create a Fraction class:
public class Fraction
public int Numerator;
public int Denominator;
public Fraction (int numerator, int denominator)
Numerator = numerator;
Denominator = denominator;
I can add a method to evaluate the fraction as a decimal value:
public double Evaluate()
return (double) Numerator / (double) Demoninator;
This uses the values that were set when the class instance was created.
Your code can do the same: set the class instance values directly when you call your method:
public MonthlyPayment alculate(int i)
Month = i;
InitialBalance =10.000f ;
Interest = ((9.75 /100) / 12) * InitialBalance;
double v = 1 + x.Interest;