❔ top level statements must precede namespace and typer declerations
I am new to C# and am using vs code. I am learning about "classes" and am getting this error
5 Replies
here is my code:
class wizard
{
public string name;
public string favouritespell;
public int spellslots;
public float experience;
}
wizard wizard1 = new wizard();
wizard1.name = "Parry Hopper";
wizard1.favouritespell = "spell1";
wizard1.spellslots = 2;
wizard1.experience = 0f;
move the class declaration under the rest of the code
(also its better to use $code blocks to show code)
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
If your code is too long, post it to: https://paste.mod.gg/thanks that worked
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.