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 trialAbigail Puckett
2,111 PointsThrowing a NullReferenceException
This code won't let me move on from the problem and it's throwing a NullReferenceException.
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);
}
}
1 Answer
Steven Parker
231,272 PointsIt looks like the only change made to the provided code so far is different parameter names, which is not part of the assignment. You'd see the same error if you just submit the original code unchanged.
This first part of the task is to change the Multiply method so it will "return the multiplied value instead of printing it". The instructions give you a head start by pointing out that "Its return value type should be double" (instead of "void").
Then, you will need to modify the Main method to make use of the return values, and to add them together instead of printing them individually.