Lennie Kuah

Lennie Kuah

  • NA
  • 29
  • 0

C#NET2008 Delegate Class Methods not working

Sep 19 2010 10:49 PM

Hi Good Guys,
I need your help. Please help me. Thank you.
I am learning how to create and use DELEGATE Class and apprently my coding at the FRMMAIN.cs which is using the DELEGATE CLASS Method propCalculate.
This is the error message generate from the FRMMAIN  :
Error 1 The name 'propcalculate' does not exist in the current context 
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);
            }
        }

HERE ARE THE DELEGATE CLASS CODING WHICH MAY NOT BE PERFECT OR CORRECT
 

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); 
                }
                                   
    }

 

Please help me. I am totally new to DELEGATE CLASS.
Thank You.
 
Have a Good Day,
Cheers,
Lennie
 

Answers (2)