CODING FROM FrmMAIN.CS
private void btnCalculate_Click(object sender, EventArgs e) { if ((this.txtLoanAmt.TextLength != 0) && (this.txtIntRate.TextLength !=0)) { txtAmt = Convert.ToDouble(this.txtLoanAmt.Text); txtInt = Convert.ToDouble(this.txtIntRate.Text); clsDelegate = new ClassDelegateCalculate.DelegateCalculate(txtAmt, txtInt) ; this.intTotalLoan = clsDelegate.propCalculate; <-----Error from here ****** intPayMth = (intTotalLoad /= 12); this.lblTotalLoan.Text = Convert.ToString(intTotalLoan); this.lblPayMth.Text = Convert.ToString(intPayMth); } }
namespace CSharpDelegate{ class ClassDelegateCalculate { //declare the DelegateCalculatonClass public delegate double DelegateCalculate(double LoanAmt, double interest); private double dblLoanAmt; private double dblInterest; //------ constructor normal -------------- public ClassDelegateCalculate() { this.dblLoanAmt = 0; this.dblInterest = 0; } //----- constructor override ------------------------------------ public ClassDelegateCalculate(double Loan, double YearInt) { this.dblLoanAmt = Loan; this.dblInterest = YearInt; } //--------class methods ------------------------------------- public Double propCalculate() //return variable back to calling Program FrmMain { //calculate interest on loan amount double dblTotalAmt; this.dblTotalAmt = ( (this.dblLoanAmt * this.dblInterest) /= 100); return (dblTotalAmt); } }}