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

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.