shimab alam
Can class exists without namespace
By shimab alam in C# on Mar 20 2014
  • Palle Technologies
    Apr, 2014 2

    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 )

    • 2
  • Piyush chhabra
    Apr, 2015 20

    yes

    • 1
  • Vishal Jadav
    Aug, 2016 15

    No. If you do not provide namespace .net will automatically pick default namespace. Default Can be found in project properties.

    • 0
  • zhang shi
    Feb, 2016 29

    YES

    • 0
  • Prasoon Abhinaw
    Sep, 2015 5

    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.

    • 0
  • Ajay Gandhi
    Aug, 2015 25

    Yes

    • 0
  • Piyush chhabra
    Apr, 2015 20

    yes

    • 0
  • Kml Surani
    Apr, 2015 15

    Yes

    • 0
  • Sunil Gaded
    Aug, 2014 28

    yes...

    • 0
  • Bhabani Prasad
    May, 2014 23

    yes,ofcourse

    • 0
  • Dasharath Vishwakarma
    May, 2014 20

    class can exists without namespace. class without namespace cannot be accessed in other namespace.

    • 0
  • Rakesh Singh
    Apr, 2014 24

    yes

    • 0
  • Munesh Sharma
    Apr, 2014 12

    yes

    • 0
  • ashok rathod
    Apr, 2014 7

    No

    • 0
  • shimab alam
    Mar, 2014 20

    Yes, namespace is used to just grouping and it is not mandatory.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS