Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to include the System namespace.
C Sharp (C#)
using [1]; class Program { static void Main() { System.Console.WriteLine("Hello World"); } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Console' instead of 'System' in the using directive.
Forgetting the semicolon after the using statement.
✗ Incorrect
The 'using System;' directive allows access to the System namespace, which contains Console.
2fill in blank
mediumComplete the code to declare a namespace named MyApp.
C Sharp (C#)
namespace [1] { class Program { static void Main() { System.Console.WriteLine("Inside MyApp namespace"); } } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'System' instead of 'MyApp' as the namespace name.
Omitting the namespace keyword.
✗ Incorrect
The namespace declaration uses the keyword 'namespace' followed by the desired name, here 'MyApp'.
3fill in blank
hardFix the error by completing the using directive to access List<T>.
C Sharp (C#)
using [1]; class Program { static void Main() { var list = new List<int>(); list.Add(1); System.Console.WriteLine(list[0]); } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'System.Text' or 'System.IO' which do not contain List.
Forgetting to add the using directive for the generic collections.
✗ Incorrect
List is in the System.Collections.Generic namespace, so you must include it with a using directive.
4fill in blank
hardFill both blanks to create a namespace and use a directive for Console.
C Sharp (C#)
[1] MyNamespace { [2] System; class Program { static void Main() { Console.WriteLine("Hello from MyNamespace"); } } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'class' instead of 'namespace' for the first blank.
Omitting the using directive for System.
✗ Incorrect
The keyword 'namespace' declares a namespace, and 'using System;' allows access to Console without prefix.
5fill in blank
hardFill all three blanks to declare a namespace, include System, and define a class.
C Sharp (C#)
[1] MyApp { [2] System; [3] Program { static void Main() { Console.WriteLine("Welcome to MyApp"); } } }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'interface' instead of 'class' for the third blank.
Forgetting the using directive for System.
Omitting the namespace declaration.
✗ Incorrect
Use 'namespace' to declare the namespace, 'using System;' to access Console, and 'class' to define Program.