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 trialChristopher Kell
3,499 PointsCould someone help me out on my code? Variable Scope
So followed the video for "Variable Scope" and have the code below. If anyone can help me resolve error CS0017 that I am getting, I would greatly appreciate it.
using System;
class variablescope { static void MyMethod() { int total = 0; total += 1; Console.WriteLine("Total in MyMethod:"); Console.WriteLine(total); }
static void Main(string[] args)
{
int total = 0;
total += 10;
MyMethod();
Console.WriteLine("Total in Main:");
Console.WriteLine(total);
}
}
1 Answer
Steven Parker
231,248 PointsThis code builds and runs just fine for me. So I looked up "CS0017" and it is apparently "Program has more than one entry point defined."
My guess is that you might be combining this with one ore more other modules when you build that also contain a "Main" method. Try building it by itself and it should work.
If that's not it, or if you still need help, please make a snapshot of your workspace and post the link to it here; and also show exactly what commands you use to build and run your test.