Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C# C# Basics Methods Method Parameters

Benjamin Diehl
Benjamin Diehl
525 Points

Define Multiply

What am I doing wrong? When I run the code it works fine and spits out the expected values, but it's still wrong?

Program.cs
using System;

class Program
{
    static double Multiply(double first, double second)
    {
     return first * second;
    }

    static void Main(string[] args)
    {
Console.WriteLine(Multiply(2.5, 2));
                  Console.WriteLine(Multiply(6, 7));
    }

}

1 Answer

Steven Parker
Steven Parker
216,812 Points

The instructions say to define a "function that accepts two parameters, multiplies them together, and passes the result to Console.WriteLine", but this function returns the result instead. Outputting in Main makes it look like it's doing the right thing, but it doesn't conform to the instructions.

The comments that were originally in the code also said "Remember to use the "static" and "void" keywords"