Discussion:
non invocable member cannot be used like a method
(too old to reply)
mp
2016-12-09 14:59:05 UTC
Permalink
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
mp
2016-12-09 16:36:53 UTC
Permalink
Post by mp
Hi, newb trying to learn c#.
think i figured it out

property vs method

property {}
method (){}

i was missing parens on
private void CalculateVolume() { }



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Continue reading on narkive:
Search results for 'non invocable member cannot be used like a method' (Questions and Answers)
3
replies
Changing this VB Code to C#?
started 2008-12-03 07:40:52 UTC
programming & design
Loading...