Challenge - 5 Problems
C# .NET Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of async method with Task.Delay
What is the output of this C# code snippet when run?
C Sharp (C#)
using System; using System.Threading.Tasks; class Program { static async Task Main() { Console.WriteLine("Start"); await Task.Delay(1000); Console.WriteLine("End"); } }
Attempts:
2 left
💡 Hint
Remember that await pauses the method until the delay finishes.
✗ Incorrect
The program prints "Start" first, then waits 1 second due to Task.Delay, then prints "End".
🧠 Conceptual
intermediate1:30remaining
Why use C# with .NET for cross-platform apps?
Which reason best explains why C# with .NET is a good choice for building cross-platform applications?
Attempts:
2 left
💡 Hint
Think about what .NET runtime offers beyond just the language.
✗ Incorrect
The .NET runtime and libraries support multiple operating systems, so C# apps can run cross-platform without rewriting.
🔧 Debug
advanced2:30remaining
Identify the error in this C# code using LINQ
What error will this code produce when compiled or run?
C Sharp (C#)
using System; using System.Linq; class Program { static void Main() { var numbers = new int[] {1, 2, 3, 4}; var result = numbers.Select(x => x > 2 ? x * 2 : 0); foreach(var n in result) { Console.WriteLine(n); } } }
Attempts:
2 left
💡 Hint
Check the syntax inside the lambda expression.
✗ Incorrect
The lambda uses 'x * 2 if x > 2' which is invalid syntax in C#. Conditional expressions require the ternary operator.
❓ Predict Output
advanced2:00remaining
Output of pattern matching with switch expression
What is the output of this C# code using pattern matching?
C Sharp (C#)
using System; class Program { static void Main() { object obj = 42; string result = obj switch { int i when i > 50 => "Large number", int i => $"Number {i}", _ => "Unknown" }; Console.WriteLine(result); } }
Attempts:
2 left
💡 Hint
Check which pattern matches the value 42.
✗ Incorrect
42 is an int but not greater than 50, so the second pattern matches and prints "Number 42".
🧠 Conceptual
expert3:00remaining
Why is .NET ecosystem beneficial for enterprise development?
Which statement best explains a key benefit of using the .NET ecosystem in enterprise software development?
Attempts:
2 left
💡 Hint
Think about what enterprises need: reliability, scalability, and support.
✗ Incorrect
The .NET ecosystem offers many libraries, tools, and community support that help enterprises build robust applications faster.