Search
Setup for Free
C
C#
•
3y 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
#
C#
Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,237
Members
View on Discord
Similar Threads
Was this page helpful?
Yes
No
© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
P
Pobiega
•
9/7/23, 7:24 AM
C
# is project based
, not file based
.
You can only have
"top level statements
" in one file per project
P
Pobiega
•
9/7/23, 7:24 AM
Usually
"Program
.cs
"
N
nux
OP
•
9/7/23, 7:24 AM
mkays
N
nux
OP
•
9/7/23, 7:24 AM
so what should i do
N
nux
OP
•
9/7/23, 7:24 AM
to fix this
N
nux
OP
•
9/7/23, 7:25 AM
delete the other 2 module
.cs files
>
P
Pobiega
•
9/7/23, 7:25 AM
that would work
, but Im kinda guessing you want those use those files somehow
?
P
Pobiega
•
9/7/23, 7:25 AM
deleting them would thus
.
. delete them
:p
N
nux
OP
•
9/7/23, 7:25 AM
yeah
N
nux
OP
•
9/7/23, 7:25 AM
i have em all commented out btw
N
nux
OP
•
9/7/23, 7:25 AM
so those are just comments
N
nux
OP
•
9/7/23, 7:25 AM
also this just happened now
P
Pobiega
•
9/7/23, 7:25 AM
well thats why
N
nux
OP
•
9/7/23, 7:26 AM
else it was good before
P
Pobiega
•
9/7/23, 7:26 AM
if you emptied them out entirely
, they count as top level statement files
N
nux
OP
•
9/7/23, 7:26 AM
o
N
nux
OP
•
9/7/23, 7:26 AM
so
N
nux
OP
•
9/7/23, 7:26 AM
ii should remove the comment outs
?
P
Pobiega
•
9/7/23, 7:26 AM
that
, or the files
S
SinFluxx
•
9/7/23, 7:27 AM
I didn
't think you could start class names with numbers
?
S
SinFluxx
•
9/7/23, 7:27 AM
(as a separate issue
)
P
Pobiega
•
9/7/23, 7:28 AM
not classes
, but files you can
N
nux
OP
•
9/7/23, 7:28 AM
well
N
nux
OP
•
9/7/23, 7:28 AM
deleting the files solved it
N
nux
OP
•
9/7/23, 7:28 AM
guess i gotta store code in txt files now
N
nux
OP
•
9/7/23, 7:28 AM
xd
P
Pobiega
•
9/7/23, 7:29 AM
nah
. use something like Obsidian to keep notes and snippets
N
nux
OP
•
9/7/23, 7:29 AM
whats that
N
nux
OP
•
9/7/23, 7:29 AM
an application
?
P
Pobiega
•
9/7/23, 7:29 AM
a notetaking application
N
nux
OP
•
9/7/23, 7:29 AM
i see
N
nux
OP
•
9/7/23, 7:29 AM
thanks a lot
, i ll try that
P
Pobiega
•
9/7/23, 7:29 AM
its my personal favorite
N
nux
OP
•
9/7/23, 7:30 AM
damn
A
Angius
•
9/7/23, 7:30 AM
Or just Markdown files in a Github repo
, which is what I do
¯\_(ツ)_/¯
N
nux
OP
•
9/7/23, 7:30 AM
might as well
P
Pobiega
•
9/7/23, 7:30 AM
thats what obsidian does
:p
N
nux
OP
•
9/7/23, 7:30 AM
yal smart af
A
Angius
•
9/7/23, 7:30 AM
Well
, that
's what it
can
do
A
Angius
•
9/7/23, 7:30 AM
If you use the Git plugin and all
P
Pobiega
•
9/7/23, 7:30 AM
its a markdown editor
, and your
"storage
" is just a folder that can be git
-
i
n
i
t
:ed if you want
A
Angius
•
9/7/23, 7:31 AM
Alas
, it
's not supported on the mobile app
P
Pobiega
•
9/7/23, 7:31 AM
true
, but how often do you write code on your phone
?
N
nux
OP
•
9/7/23, 7:31 AM
yeah
N
nux
OP
•
9/7/23, 7:31 AM
never
N
nux
OP
•
9/7/23, 7:31 AM
that would be a headache
N
nux
OP
•
9/7/23, 7:32 AM
how do I close this
N
nux
OP
•
9/7/23, 7:32 AM
!solved
N
nux
OP
•
9/7/23, 7:32 AM
o
P
Pobiega
•
9/7/23, 7:33 AM
$close
Next page
Similar Threads
❔ Only one compilation unit can have top-level statements. [C# start]
C
C# / help
3y ago
❔ Only one compilation unit can have top level statements err simple explanation
C
C# / help
3y ago
Only one compilation unit can have top-level statements. [Project]csharp(CS8802) [Answered]
C
C# / help
4y ago
❔ "Only one compilation can have top level statements" please help
C
C# / help
3y ago