Sign in to follow this  
ThoughtCriminal

New to C#, probly dumb problem ahead:

Recommended Posts

Here's my code: [CODE] using System; using System.Collections.Generic; using System.Text; namespace ConsoleLearning { class Program { static void Main(string[] args) { Console.SetWindowSize(80, 40); Console.SetBufferSize(160, 80); enum Letters {A=65,B,C,D,E,F,H,I,J,K}; int n = 0; do { for (int i = 0; i < 10; i++) { Console.CursorLeft = i; Console.CursorTop = i; // Console.Write((char)Letters]); } } while (n == 0); } } } [/CODE] Everyting was working fine until I added to line with the enum. Accoring to MSDN an enum is delared like this: enum Days {Sat=1, Sun, Mon, Tue, Wed, Thu, Fri}; I really have no idea how to fix this, any help appreciated. Thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by Alpha_ProgDes
you should be able to declare in or outside of main() shouldn't you?

No, 'enum' is a type declaration which cannot be done inside any method.

Share this post


Link to post
Share on other sites
Thank you, what is a type and what is not is still confusing to me.

Now I have what I wanted.
[CODE]
for (int i = 0; i < 10; i++)
{
Console.CursorLeft = i;
Console.CursorTop = i;

Console.Write(Letters.A+i);
}
[/CODE]

Where is the help page for how to use code tags etc?


Share this post


Link to post
Share on other sites
Quote:
Original post by ThoughtCriminal
what is a type

Everything that you can put in front of the name of a variable in a declaration is a type.

Share this post


Link to post
Share on other sites
Quote:
Original post by ThoughtCriminal
Where is the help page for how to use code tags etc?

See that little link near the top of the page titled "faq"? It includes a section describing allowed tags. In your case, just use lower case, instead of upper case. Or alternatively, use "source" instead of "code" to get a nice scrollable box.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this