Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

C# C# Objects Loops and Final Touches Static Members

Luis Santos
Luis Santos
3,566 Points

I am stumped, I really don't know where to even begin with this.

I need serious help with this, I can understand some of the instructions but I am generally lost.

RightTriangle.cs
namespace Treehouse.CodeChallenges
{
    class RightTriangle
    {
        static CalculateHypotenuse =

    }
}

1 Answer

Steven Parker
Steven Parker
230,248 Points

Relax and take it a step at a time. You already have the name of the method and the "static". (But lose the "=').

  • Be sure to put "public" before the static so another part of the program can use this method.
  • After static you'll put the return type. The challenge said to "return a double".
  • After the name you'll put the parameters (name them) between parentheses. Challenge said "two... type double".
  • Then you'll put some braces ({}) to enclose the body of the method.
  • Inside that you'll put a return with some math to calculate the result.
  • Look up the Pythagorean theorem if you're not familiar. It involves doing things with squares and square roots.
  • Squares are easy. Roots can be done with Math.Sqrt(). Remember to put using System; up top.
  • Once you get that fixed up, check your work. You should be there or need very minor tweaking.

Hope that helps. Happy coding!   -sp:sparkles: