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

Did you find this page helpful?