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

Shouldn't this be correct code for the question? C#

Check the code, why does it keep saying its wrong?

Program.cs
using System;

class Program
{

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


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

}

2 Answers

Daniel Turato
seal-mask
PLUS
.a{fill-rule:evenodd;}techdegree seal-36
Daniel Turato
Java Web Development Techdegree Graduate 30,124 Points

The challenge requires you not to return the result from multiply but instead output to the console. So you should change the return type on the multiply method from double to void and output the result in that method instead of Main. Otherwise, everything else looks good.

How would it go with that method? Im stuck

How would it go with that method? Im stuck

Daniel Turato
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Daniel Turato
Java Web Development Techdegree Graduate 30,124 Points

So your code should look like this

using System;

class Program
{

    static void Multiply(double first, double second)
    {
        Console.WriteLine(first*second);
    }


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

}

using System;

class Program {

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

static void Main(string[] args)
{
    double total = Multiply(2.5, 2);
    double total2 = Multiply(6, 7);
    Console.WriteLine(total + (total2));

}

}

That is the code that will pass the challenge dear brothers...