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 trialAlex Barnhart
Courses Plus Student 5,767 Pointshow to return in a void object
I keep getting the error surrounding "in a void object, return values cannot be followed by objects or expressions".
using System;
class Program
{
static double Multiply(double firstParam, double secondParam)
{
return firstParam * secondParam;
}
static void Main(string[] args)
{
return Multiply(2.5, 2) + Multiply(6, 7);
}
}
1 Answer
Steven Parker
231,271 PointsIn a method, the "void" type means "this method does not return anything".
So if you want the method to return something, the method's type must match the type of thing that will be returned. But in this case, the instructions don't ask you to return the result, they say you should "print the result" instead.