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#

Liam Andersson
Liam Andersson
1,396 Points

I have 6 errors in my code. I cant see them in the code

I get error but I can't figure out where they are. I'm using some things that I've never used before though. Help? File: Egen.cs https://w.trhou.se/s2gmgfowsi

1 Answer

Steven Parker
Steven Parker
231,122 Points

Only the first error listed is is significant. And sometimes you need to look at the line before the one mentioned by the error message to see the real issue.

In this case, you are missing the semicolon at the end of line 8.

Fixing that will reveal some other errors, but hopefully you can take it from there.

Liam Andersson
Liam Andersson
1,396 Points

Ah Okay, I thought the whole code was a Huge error. Thanks again Steven!

Liam Andersson
Liam Andersson
1,396 Points

Steven, I did as you said and I got some errors after it and I fixed them all, except one. It's the one with the new "function" I wanted to try out! I wanted a random number so I searched it up and then wrote this into my Egen.cs file:

Random random = new Random();
int randomNumber = random.Next(1,10);

My errors are: error CS0246: The type or namespace name Random' could not be found. Are you missingSystem' using directive?

Steven Parker
Steven Parker
231,122 Points

It's hinting for you to add a "using System;" directive to the top of your file, if you don't have one already.

If that's not it, create a new question (with a fresh snapshot).

Liam Andersson
Liam Andersson
1,396 Points

It worked thanks.. I didnt even think of adding that..