C
C#17mo ago
nux

✅ Only one compilation unit can have top-level statements

my program.cs suddenly started giving me this error, I use visual studio code btw and I am a beginner at c#
29 Replies
Pobiega
Pobiega17mo ago
C# is project based, not file based. You can only have "top level statements" in one file per project Usually "Program.cs"
nux
nuxOP17mo ago
mkays so what should i do to fix this delete the other 2 module.cs files>
Pobiega
Pobiega17mo ago
that would work, but Im kinda guessing you want those use those files somehow? deleting them would thus.. delete them :p
nux
nuxOP17mo ago
yeah i have em all commented out btw so those are just comments also this just happened now
Pobiega
Pobiega17mo ago
well thats why
nux
nuxOP17mo ago
else it was good before
Pobiega
Pobiega17mo ago
if you emptied them out entirely, they count as top level statement files
nux
nuxOP17mo ago
o so ii should remove the comment outs?
Pobiega
Pobiega17mo ago
that, or the files
SinFluxx
SinFluxx17mo ago
I didn't think you could start class names with numbers? (as a separate issue)
Pobiega
Pobiega17mo ago
not classes, but files you can
nux
nuxOP17mo ago
well deleting the files solved it guess i gotta store code in txt files now xd
Pobiega
Pobiega17mo ago
nah. use something like Obsidian to keep notes and snippets
nux
nuxOP17mo ago
whats that an application?
Pobiega
Pobiega17mo ago
a notetaking application
nux
nuxOP17mo ago
i see thanks a lot, i ll try that
Pobiega
Pobiega17mo ago
its my personal favorite
nux
nuxOP17mo ago
damn
Angius
Angius17mo ago
Or just Markdown files in a Github repo, which is what I do ¯\_(ツ)_/¯
nux
nuxOP17mo ago
might as well
Pobiega
Pobiega17mo ago
thats what obsidian does :p
nux
nuxOP17mo ago
yal smart af
Angius
Angius17mo ago
Well, that's what it can do If you use the Git plugin and all
Pobiega
Pobiega17mo ago
its a markdown editor, and your "storage" is just a folder that can be git-init:ed if you want
Angius
Angius17mo ago
Alas, it's not supported on the mobile app
Pobiega
Pobiega17mo ago
true, but how often do you write code on your phone?
nux
nuxOP17mo ago
yeah never that would be a headache how do I close this !solved o
Pobiega
Pobiega17mo ago
$close
MODiX
MODiX17mo ago
Use the /close command to mark a forum thread as answered

Did you find this page helpful?