C# Corner
Tech
News
Videos
Forums
Trainings
Books
Events
More
Interviews
Jobs
Live
Learn
Career
Members
Blogs
Challenges
Certifications
Bounties
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
.NET
ADO.NET
Android
ASP.NET
C#
Databases & DBA
Design Patterns & Practices
Java
Learn iOS Programming
OOP/OOD
SharePoint
Software Testing
Web Development
WPF
View All
15
Reply
Can class exists without namespace
shimab alam
11y
18.5k
0
Reply
Delete Row
Delete Column
Insert Link
×
Insert
Cancel
Embed YouTube Video
×
Width (%)
Height (%)
Insert
Cancel
Table Options
×
Rows
Columns
First row as header
Create Table
Insert Image
×
Selected file:
Alignment
Left
Center
Right
Select an image from your device to upload
Upload to Server
Cancel
Submit
It is impossible to create a class without having a namespace . But in asp.net we can create a class without having a namespace , in this case asp.net compiler will add a namespace called global under which the classes will be added . For testing this open an asp.net website create class with the name Class1 in a.aspx.cs file , create one more file with the same class name that is Class1 . Now try to compile and execute code . You will definitely get an error stating global namespace is already having the class with the name Class1 . Hence it is not possible to create a class without a name space ( incase of asp.net if you skip namespace asp.net will create one for you with the name global )
Palle Technologies
11y
2
yes
Piyush chhabra
10y
1
No. If you do not provide namespace .net will automatically pick default namespace. Default Can be found in project properties.
Vishal Jadav
9y
0
YES
zhang shi
9y
0
The correct answer is No. But in terms of .net implementation part you can create without namespace and compiler will add that class under namespace
at run time.
Prasoon Abhinaw
10y
0
Yes
Ajay Gandhi
10y
0
yes
Piyush chhabra
10y
0
Yes
Kml Surani
10y
0
yes...
Sunil Gaded
11y
0
yes,ofcourse
Bhabani Prasad
11y
0
class can exists without namespace. class without namespace cannot be accessed in other namespace.
Dasharath Vishwakarma
11y
0
yes
Rakesh Singh
11y
0
yes
Munesh Sharma
11y
0
No
ashok rathod
11y
0
Yes, namespace is used to just grouping and it is not mandatory.
shimab alam
11y
0
Message