C# Programming - Namespaces - Discussion

Discussion :: Namespaces - General Questions (Q.No.14)

14. 

Which of the following C#.NET code snippets will correctly print "Hello C#.NET"?

[A].
import System; 
namespace IndiabixConsoleApplication
{ 
    class MyProgram
    { 
        static void Main(string[] args)
        { 
            Console.WriteLine("Hello C#.NET");
        } 
    } 
}
[B].
using System;
namespace IndiabixConsoleApplication
{ 
    class MyProgram
    { 
        static void Main(string[ ] args)
        { 
            WriteLine("Hello C#.NET");
        } 
    } 
}
[C].
using System.Console; 
namespace IndiabixConsoleApplication
{ 
    class MyProgram
    { 
        static void Main (string[ ] args)
        { 
            WriteLine("Hello C#.NET");
        } 
    } 
}
[D].
using System;
namespace IndiabixConsoleApplication
{ 
    class MyProgram
    { 
        static void Main(string[] args)
        { 
            Console.WriteLine("Hello C#.NET");
        }
    }
}

Answer: Option D

Explanation:

No answer description available for this question.

Sachin said: (Jun 22, 2012)  
Whats wrong with option [A] ?

Veyronash said: (Apr 13, 2013)  
In Option A, System is a namespace and it has to be used with a using keyword and not import.

Radhakrishna said: (Jan 3, 2015)  
Hello What's wrong with option C?

Henok said: (Nov 30, 2018)  
Option C: the namespace is importing the Console class, then it imported as " using static System. Console;" rather than "using System. Console; ".

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.