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 Return Values

Paul McCormick
Paul McCormick
9,816 Points

Im Really not understanding what i need to do here! I've set the static from void to double, string, int etc and I don'

Program.cs
using System;

class Program
{

    static return Multiply(double firstParam, double secondParam)
    {
        Console.WriteLine(firstParam * secondParam);
    }

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

}

1 Answer

Telmo Sampaio
Telmo Sampaio
16,877 Points

Hey Paul,

static double Multiply(double firstParam, double secondParam)
{
    return firstParam * secondParam;
}

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

Your Multiply function need to be with a return type of double, at the moment you have "return", then inside of the function you need to use the keyword return to return those values in the function, hope this helps

Paul McCormick
Paul McCormick
9,816 Points

That worked perfectly Telmo, Thank you very much. My mind was only going round changing the static element and i could't grasp in my mind to set double a, b to equals multiply. I think i will resit this module until i fully understand it. Once again, Thank you.