Chapter 1 – Hello, C#! Welcome, .NET! Flashcards

1
Q

Is Visual Studio 2022 better than Visual Studio Code?

A

No. Each is optimized for different tasks. Visual Studio 2022 for Windows is large, heavyweight, and can create applications with graphical user interfaces, for example, Windows Forms, WPF, UWP, and .NET MAUI apps, but it is only available on Windows. Visual Studio 2022 is an Interactive Development Environment (IDE) rather than a code editor. Visual Studio Code is smaller, lighter-weight, code-focused, supports many more languages, and is available cross-platform.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Is .NET 5 and later better than .NET Framework?

A

For modern development, yes, but it depends on what you need. .NET 5 and later are
modern, cross-platform, performance-oriented versions of the legacy, mature .NET Framework.
Modern .NET is more frequently improved. .NET Framework has better support for legacy
applications; however, .NET Framework 4.8 will be the last release apart from security and
bug fixes. It will never support some language features of C# 8 and later.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is .NET Standard and why is it still important?

A

.NET Standard defines an API, aka contract, that a .NET platform can implement. The
latest versions of .NET Framework, Xamarin, and modern .NET implement .NET Standard 2.0
to provide a single, standard API that developers can target for maximum reuse. .NET Core 3.0
or later implement .NET Standard 2.1, which has some new features not supported by .NET
Framework. If you want to create a new class library that supports all .NET platforms you will
need it to be .NET Standard 2.0-compatible.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why can a programmer use different languages, for example, C# and F#, to write applications
that run on .NET?

A

Multiple languages are supported on .NET because each one has a compiler that
translates the source code into intermediate language (IL) code. This IL code is then compiled
to native CPU instructions at runtime by the Common Language Runtime (CLR).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a top-level program and how do you access any command-line arguments?

A

A top-level program is a project that does not need to explicitly define a Program class
with a Main method entry point, with a parameter named args, to access any command-line
arguments. These are implicitly defined for you so that you can type statements without boilerplate code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the name of the entry point method of a .NET console app and how should it be explicitly declared if you are not using the top-level program feature?

A

The entry point of a .NET console app is the Main method. An optional string array
for command-line arguments and a return type of int are recommended, but they are not
required. They can be explicitly declared, as shown in the following code:

public static void Main() // minimum
public static int Main(string[] args) // recommended

With .NET 6 and later, it is implicitly declared using the top-level program feature, as shown
in the following code:
public static int <Main>$(String[] args) // compiler-generated

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What do you type at the command line to build and execute C# source code?

A

In a folder with a .csproj file, you enter dotnet run.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly