-7

I'm looking for an answer to the following:

Desired behaviour

Round the mathematical constant pi to 2 or 4 decimals.

Current code

I have tried the following:

Double piRounded;
piRounded = Math.Round.PI(4);
piRounded = Math.Round.PI(2);

Current result

This results in the following error:

'System.Math.Round(double)' is a 'method', which is not valid in the given context

2 Answers2

0

Math.Round in your code is being specified as a property, not a method invocation.

Place your parameters in the round function like Math.Round(...) - You will want to pass in the PI constant.

Math.Round(Math.PI, 4) (as stated in comments).

Miek
  • 1,190
  • 7
  • 18
0

Use:

Math.Round(Math.PI, 2);

and

Math.Round(Math.PI, 4);

respectively