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

Jourdan Dixon
Jourdan Dixon
4,752 Points

what am I missing?

can someone help me? I have been stuck on this for weeks? I am not sure what I am doing wrong

Program.cs
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 )
    {
        return first * second;

    }

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

        // YOUR CODE HERE:
        // Call Multiply with two arguments: 2.5 and 2.
        // YOUR CODE HERE:
        // Call Multiply with two arguments: 6 and 7.
    }

}

1 Answer

Steven Parker
Steven Parker
229,732 Points

The instructions ask for a "function that accepts two parameters, multiplies them together, and passes the result to Console.WriteLine"

These issues stand out at first glance:

  • the WriteLine should be done inside the function
  • the function can't return anything because it is "void"
  • the main section should only call the function
  • no "total" variable is needed, and nothing is returned for assignment