Interviews31 answers
Can class exists without namespace
31 Answers
Yes
Mukesh KumarPosted Sep 12, 2017, 6:07 AM EDT
Yes, class can exists without namespace
Ayappan AlagesanPosted Feb 11, 2017, 8:38 PM EST
Yes of-course. Namespaces are only meant to avoid the conflict of duplicate class names.
Vineet KumarPosted Jan 12, 2017, 9:02 PM EST
Yes Class can exist without namespace, It will be in the global namespace and can be referenced like this:
var cls = new global::test();
Avikshith AradhyaPosted Jun 3, 2016, 2:33 AM EDT
Its actually possible to create a class without any namespace in .net. However, it takes the global namespace.
Raghvandra ShuklaPosted Mar 27, 2016, 5:16 AM EDT
Its actually possible to create a class without any namespace in .net. However, it takes the global namespace.
Raghvandra ShuklaPosted Mar 27, 2016, 5:16 AM EDT
Its actually possible to create a class without any namespace in .net. However, it takes the global namespace.
Raghvandra ShuklaPosted Mar 27, 2016, 5:15 AM EDT
Its actually possible to create a class without any namespace in .net. However, it takes the global namespace.
Raghvandra ShuklaPosted Mar 27, 2016, 5:15 AM EDT
Yes we can create class without namespace.
Ashish SrivastavaPosted Dec 20, 2015, 7:35 AM EST
no
lokesh kumarPosted Dec 18, 2015, 2:10 AM EST
yes.
Sridhar SharmaPosted Nov 12, 2015, 11:44 PM EST
yes we can create
Akash VarshneyPosted Oct 10, 2015, 3:41 AM EDT
yes
Pramod GuptaPosted Sep 23, 2015, 8:58 AM EDT
yes
Pramod GuptaPosted Sep 23, 2015, 8:54 AM EDT
yes
Ajeet MishraPosted Sep 3, 2015, 5:09 AM EDT
Yes Using Global Namespace a class can exist without namespace
Pankaj Kumar ChoudharyPosted Aug 31, 2015, 9:10 AM EDT
Yes I tried. Application working fine . I can access that class. I guess it class should take global namespace
Ajay GandhiPosted Aug 25, 2015, 3:40 AM EDT
Its actually possible to create a class without any namespace in .net. However, it takes the global namespace, which is the project name unless it has been explicitly changed the default namespace while creating or after creation of any .net project
https://msdn.microsoft.com/en-us/library/c3ay4x3d(VS.80).aspx
Shakti SaxenaPosted Aug 18, 2015, 7:08 AM EDT
Yes, class can exist without namespace. We can declare multiple inter-related classes under one namespace and can access those classes by using that namespace. Otherwise its not mandatory to declare a namespace but its a good practice.
Sanjukta PearlPosted Aug 18, 2015, 5:38 AM EDT
Yes.
Sachin KumarPosted Jul 24, 2015, 9:31 PM EDT
Never because namespace is collection of classes , so we cannt imagine the clase without namespace
Vivek Kumar VishwasPosted Jul 22, 2015, 1:34 AM EDT
I myself never have seen any classes without namespace, please explain if you have seen class without namespace.
Joe WilsonPosted Jul 20, 2015, 5:03 AM EDT
Yes, class can exists without name space
example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("hello world");
}
}
Output: hello world
Vvs MurthyPosted Jul 16, 2015, 7:52 AM EDT
yes
Sreekanth ReddyPosted Jul 10, 2015, 10:11 PM EDT
Yes, you can create the classes without name space.
The name space is used the classes that can have the same name to differ.
Frank Núñez RodríguezPosted Jul 9, 2015, 7:18 AM EDT
yes.
But me need to specify the path of each key word when it is using. By using name space we can reduce the length of our code.
Alex VarghesePosted Jul 6, 2015, 5:19 AM EDT
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 )
Pankaj Kumar ChoudharyPosted Jul 2, 2015, 8:30 AM EDT
Yes class can exists without namespace.
public class WithoutNameSpace
{
public void display()
{
System.Console.WriteLine("WithoutNameSpace");
}
}
--
class Program
{
static void Main(string[] args)
{
WithoutNameSpace ob = new WithoutNameSpace();
ob.display();
}
}
Abrar Ahmad AnsariPosted Jul 1, 2015, 1:36 AM EDT
No
Munesh SharmaPosted Jun 28, 2015, 7:51 AM EDT
To make the .Net Framework more maintainable Microsoft has given it a hierarchical structure. This hierarchical structure is organized into container called Namespace. Like all .Net Framework classes organized into "System" namespace. So its necessary that a class exist inside a namespace.
Sujeet SumanPosted Jun 26, 2015, 1:20 AM EDT
No, Without Namespace class can never exists.
Sudheshwer RaiPosted Jun 25, 2015, 9:45 PM EDT


















