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#

how do I do the Method parameters question in c#.

hi I cant figure out what to do in the method parameters question. I never really understood the double first double second things well, so I got confused. the question gave me a lot of info, which was helpful but I still didn't understand. I know this code is very wrong but I don't know how to fix it. this is my code below. please help!!!

using System;

class Program { satic Void Multiply(double frirst, double second) {

       Multiply(first + second);

   }


static void Main(string[] args)
{

   Console.WriteLine.Multiply(2.5, 2);
   Console.WriteLine.Multiply(6, 7);

}

}

Simon Coates
Simon Coates
8,223 Points

Your question doesn't seem to have linked to a particular video or quiz (which would allow a user to understand the context). You could however provide a URL.

1 Answer

Simon Coates
Simon Coates
8,223 Points

It accepts:

using System;

class Program
{

    // YOUR CODE HERE: Define a method named Multiply. Remember
    // to use the "static" and "void" keywords: "static void
    // Multiply" (without quotes). Multiply should take two
    // "double" values as parameters.
    static void Multiply(double first, double second)
    {
       double product = first * second;   
       Console.WriteLine(product); 
    }

    static void Main(string[] args)
    {
        // YOUR CODE HERE:
        Multiply(2, 2.5);
        // YOUR CODE HERE:
        Multiply(6, 7);
    }
}

You have a couple spelling and case mistakes ('satic', 'Void', 'frirst'). The more concerning error is trying to call Multiply on Console.WriteLine. For reference, the following (which ISN'T what the challenge wants) would be how to call Multiple in the context of a call to Console.WriteLine. It would require that I alter the Multiply method to return a double (instead of using the void keyword).

using System;

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

    static void Main(string[] args)
    {
        // YOUR CODE HERE:
        Console.WriteLine(Multiply(2, 2.5));
    }
}

oof yeah. thank you Simon!!!