mp
2016-12-09 14:59:05 UTC
Hi, newb trying to learn c#.
trying to write stubs to organize thoughts about my program design
before actually implementing them.
I have a class cStone with a property .Volume
when the prop is accessed i need to calculate the volume and return
When I write a stub to do the calculation I get errors.
I have a private double variable to hold the value mdVolume
(in practice I would do a check if volume was already set so only
calculate once)
public double Volume
{get
{CalculateVolume(); //error non invocable member cannot be used like
a method
return mdVolume;
}
}
private void CalculateVolume{}; //error property or indexer must have
accessor ...(but it's not a propery it's a method or thats what i
thought i needed to do
have searched the errors and read many posts but dont' understand how to
fix this, any help appreciated
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
trying to write stubs to organize thoughts about my program design
before actually implementing them.
I have a class cStone with a property .Volume
when the prop is accessed i need to calculate the volume and return
When I write a stub to do the calculation I get errors.
I have a private double variable to hold the value mdVolume
(in practice I would do a check if volume was already set so only
calculate once)
public double Volume
{get
{CalculateVolume(); //error non invocable member cannot be used like
a method
return mdVolume;
}
}
private void CalculateVolume{}; //error property or indexer must have
accessor ...(but it's not a propery it's a method or thats what i
thought i needed to do
have searched the errors and read many posts but dont' understand how to
fix this, any help appreciated
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus