15,958,036 members
See more:
I do not have much to explain as I myself is a beginner in C#. However I wanted to calculalte the area of a triangle using its three sides. And the code is giving me error as CS0149 - Method Name Expected.

Following is my Code:
C#
```class Q6_CalculateAreaOfTriangle
{

public static void FindAreaWith3Sides(double sideA, double sideB, double sideC)
{
double perimeter = (sideA + sideB + sideC) / 2;
double pSubSidA = perimeter - sideA;
double pSubSidB = perimeter - sideB;
double pSubSidC = perimeter - sideC;
double areaRaw = perimeter(pSubSidA * pSubSidB * pSubSidC); //Here is where it gives me problem. It asks to give a method. Why is it so??
double area = Math.Sqrt(areaRaw);
}

}```

What I have tried:

Nothing. As dont know where to start from and what to look for.

However I request to please provide an explanation in very very easy to understand English as I have not covered much in C# so the things you mention I might not even have heard of.

Posted
Updated 28-Sep-18 0:39am
Herman<T>.Instance 28-Sep-18 6:28am
perimeter is a double type variable and not a method

## Solution 1

If you double click on the error message, it will take you to the line that it found teh error on. Look at the error message, and at the code:
`Method Name Expected`

`double areaRaw = perimeter(pSubSidA * pSubSidB * pSubSidC);`
There is only one
And `perimeter` is a `double` variable:
`double perimeter = (sideA + sideB + sideC) / 2;`
not a method, so it looks at your code, sees this:
`double variable = aName(parameter list);`
and expects aName to be a method. so, it complains: you can't "call" a variable, that doesn't make any sense!

I think you need to go back to basic maths: Area of a triangle given three sides - Heron's Formula - Math Open Reference[^]
So, calculate p: (a + b + c)/2
Then area = Sqrt(p * (p - a) * (p - b) * (p -c))
You've calculated p, that's fine - but you need the multiply sign:
C#
`double areaRaw = perimeter * (pSubSidA * pSubSidB * pSubSidC);`

v2