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# 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
229,732 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"