using System;
namespace area
{
class Program
{
static void Main(string[] args)
{
double basse;
double height;
Console.WriteLine("Enter your base length: ");
basse = Convert.ToDouble(Console.ReadLine());
Console.WriteLine( "Enter the height: ");
height = Convert.ToDouble(Console.ReadLine());
double area = Program.triangleArea(basse, height);
Console.WriteLine("Your area is {0:f3}", area);
Console.ReadLine();
double pryrmid = Program.pyramidVolume( triangleArea);
Console.WriteLine(" Pyramid Volume is {0:f3}" , pryrmid);
}
public static double triangleArea(double basse, double height)
{
return (0.5 * basse) * height;
}
public static double pyramidVolume (double triangleArea)
{
return (1/3) * triangleArea;
}
}
}
I’m trying the calculate the volume of a pryamid using the methods ive defined.
I keep getting the error
Argument ‘1’: cannot convert from ‘method group’ to ‘double’ (CS1503)
– \vmware-host\Shared Folders\Documents\SharpDevelop Projects\WS_6_D\WS_6_D\Program.cs:28,57
and
The best overloaded method match for
‘area.Program.pyramidVolume(double)’ has some invalid arguments
(CS1502) – \vmware-host\Shared Folders\Documents\SharpDevelop
Projects\WS_6_D\WS_6_D\Program.cs:28,34
I was wondering if someone could help me get on the right track.
The problem is that
triangleAreaindouble pryrmid = Program.pyramidVolume( triangleArea);is not a variable, hence it points to the static method.Try
double pryrmid = Program.pyramidVolume( area);instead.