98-372 · Question #115
Namespaces are used a lot in C# programming in two ways. What are those two ways? Each correct answer represents a part of the solution. Choose two.
The correct answer is B. Declaring your own namespaces C. The .NET Framework uses namespaces to organize its many classes. First, the .NET Framework uses namespaces to organize its many classes as follows: System.Console.WriteLine("Hello World!"); Here, System is a namespace and Console is a class in the namespace. The using keyword is used to avoid using the complete name. An example is given…
Question
Namespaces are used a lot in C# programming in two ways. What are those two ways? Each correct answer represents a part of the solution. Choose two.
Options
- AUse the namespace keyword to declare a namespace
- BDeclaring your own namespaces
- CThe .NET Framework uses namespaces to organize its many classes
- DUsing global namespace
How the community answered
(32 responses)- A6% (2)
- B78% (25)
- D16% (5)
Explanation
First, the .NET Framework uses namespaces to organize its many classes as follows: System.Console.WriteLine("Hello World!"); Here, System is a namespace and Console is a class in the namespace. The using keyword is used to avoid using the complete name. An example is given below: //No need to put System before Console Console.WriteLine("Hello"); Console.WriteLine("World!"); Second, declaring your own namespaces can help you to control the scope of class and method names in larger programming projects. The namespace keyword is used to declare a namespace, as in the following example: namespace SampleNamespace class SampleClass public void SampleMethod() System.Console.WriteLine("SampleMethod inside SampleNamespace");
Topics
Community Discussion
No community discussion yet for this question.