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