0
0
C Sharp (C#)programming~20 mins

Why C# and the .NET ecosystem - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
C# .NET Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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");
    }
}
AEnd
BEnd\nStart
CStart
DStart\nEnd
Attempts:
2 left
💡 Hint
Remember that await pauses the method until the delay finishes.
🧠 Conceptual
intermediate
1: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?
A.NET provides a runtime and libraries that work on Windows, Linux, and macOS, enabling cross-platform apps.
BC# code runs only on Windows, so it is optimized for that OS.
CC# requires rewriting code for each platform separately.
DC# does not support modern programming features needed for cross-platform apps.
Attempts:
2 left
💡 Hint
Think about what .NET runtime offers beyond just the language.
🔧 Debug
advanced
2: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);
        }
    }
}
AOutput: 6 8
BRuntime error: NullReferenceException
CSyntaxError: Invalid expression in lambda
DOutput: 2 4 6 8
Attempts:
2 left
💡 Hint
Check the syntax inside the lambda expression.
Predict Output
advanced
2: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);
    }
}
AUnknown
BNumber 42
CLarge number
DCompilation error
Attempts:
2 left
💡 Hint
Check which pattern matches the value 42.
🧠 Conceptual
expert
3: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?
A.NET provides a rich set of libraries, tools, and a strong community that accelerates building reliable, scalable enterprise apps.
B.NET apps cannot integrate with cloud services, which reduces complexity.
C.NET ecosystem limits developers to only one programming language, simplifying training.
D.NET requires manual memory management, giving enterprises full control over resources.
Attempts:
2 left
💡 Hint
Think about what enterprises need: reliability, scalability, and support.