Click here to Skip to main content
15,889,992 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
class appliance
       { 
double soln1,soln2,soln3...soln20;

public double Total {

         get {
               return Total;
                  }

          set {
  Total=soln1+soln2+soln3......soln20;
                  }
             }

             }
Posted
Updated 12-Aug-15 10:38am
v2
Comments
Member 11905056 12-Aug-15 17:17pm    
thanx..your the best.the exception is gone
thou its not displaying the total in the next page..

1 solution

It looks like you're having a recursion in your code. The
C#
return Total;

Actually calls the Total getter again and this calls it again and so on.

In order to store the value you should have a backing variable which you would use internally in the class. So something like:
C#
class appliance
       {
double soln1,soln2,soln3...soln20;

private double _total;

public double Total {

         get {
               return this._total;
                  }

          set {
  this._total=soln1+soln2+soln3......soln20;
                  }
             }

However, the setter looks a bit odd since you set the value based on other variables than what is passed to the property. Re-check that the code is as required or should you use
C#
set {
    this._total=value;
        }
 
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