adplus-dvertising
frame-decoration

Question

If a class named csharp is present in namespace n1 as well as in namespace n2,then which of the following is the correct way to use csharp class?
a) class Program
   {
     static void Main(string[] args)
     {
        import n1;
        csharp x = new csharp();
        x.fun();
        import n2;
        csharp y = new csharp();
        y.fun();
     }
   }

b) import n1;
   import n2;
   namespace ConsoleApplication1
   {
      class Program
   {
     static void Main(string[] args)
     {
 
       n1.csharp x = new n1.csharp();
        x.fun();
        import n2;
        n2.csharp y = new n2.csharp();
        y.fun();
     }
   }
}

c)   class Program
   {
     static void Main(string[] args)
     {
       using n1;
       csharp x = new csharp();
       x.fun();
       using n2;
       csharp y = new csharp();
        y.fun();
     }
   }

d) using n1;
   using n2;
   namespace ConsoleApplication1
   {
      class Program
   {
     static void Main(string[] args)
     {
 
       n1.csharp x = new n1.csharp();
        x.fun();
        import n2;
        n2.csharp y = new n2.csharp();
        y.fun();
     }
   }
}

a.

a

b.

b

c.

c

d.

d

Posted under C# programming

Answer: (c).c

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. If a class named csharp is present in namespace n1 as well as in namespace n2,then which of the following is the correct way to use csharp class?