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

.NET SDK Installation and Setup in C Sharp (C#) - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to print the .NET runtime version installed on your machine.

C Sharp (C#)
Console.WriteLine(".NET Runtime Version: " + [1]);
Drag options to blanks, or click blank then click option'
AEnvironment.GetEnvironmentVariable("DOTNET_VERSION")
BSystem.Environment.Version.ToString()
Cdotnet --version
DConsole.ReadLine()
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to run shell commands like 'dotnet --version' directly in code.
Using Console.ReadLine() which waits for user input instead of showing version.
2fill in blank
medium

Complete the code to create a new console project using the .NET CLI command.

C Sharp (C#)
var process = new System.Diagnostics.Process();
process.StartInfo.FileName = "dotnet";
process.StartInfo.Arguments = "[1]";
process.Start();
Drag options to blanks, or click blank then click option'
Abuild console
Bcreate console
Cinit console
Dnew console
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'create' or 'init' which are not valid dotnet commands.
Using 'build' which compiles but does not create a project.
3fill in blank
hard

Fix the error in the code that tries to check if the .NET SDK is installed by running 'dotnet --version'.

C Sharp (C#)
var process = new System.Diagnostics.Process();
process.StartInfo.FileName = "dotnet";
process.StartInfo.Arguments = "[1]";
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = false;
process.Start();
Drag options to blanks, or click blank then click option'
A--version
Bshow-version
Cversion
D-version
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-version' or 'version' without double dashes.
Setting UseShellExecute to true which prevents output redirection.
4fill in blank
hard

Fill both blanks to install the latest .NET SDK using the command line.

C Sharp (C#)
string command = "dotnet [1] [2]";
Drag options to blanks, or click blank then click option'
Ainstall
Bupdate
Cnew
Dupgrade
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'new' which creates projects, not installs SDK.
Using 'upgrade' which is not a dotnet CLI command.
5fill in blank
hard

Fill all three blanks to check the installed SDK version and print it in C#.

C Sharp (C#)
var process = new System.Diagnostics.Process();
process.StartInfo.FileName = "dotnet";
process.StartInfo.Arguments = "[1]";
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.UseShellExecute = [2];
process.Start();
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
Console.WriteLine("Installed SDK version: " + [3]);
Drag options to blanks, or click blank then click option'
A--version
Bfalse
Coutput
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Setting UseShellExecute to true which disables output redirection.
Using wrong argument like '-version' or 'version'.
Printing the wrong variable instead of the output.