This project contains the source code for the book Essential C# by Mark Michaelis (Addison-Wesley).
Open a console and change the working directory to the desired project location.
git clone https://github.com/IntelliTect/EssentialCSharp.git
cd ./EssentialCSharp/
The source code is the most recently published edition of the book and this is the default branch following the clone command. However, you can switch to a different branch, v12.0 for example, with the command:
git checkout v12.0
Navigate to the root directory of the EssentialCSharp from your local terminal (the root directory is the one that contains the EssentialCSharp.sln
file).
From that root directory, run the following commands to restore and build all the projects:
dotnet restore
dotnet build
To run the code, first navigate to the project directory of the chapter you wish to execute. For example, to execute the samples in Chapter 1, you would navigate to the Chapter01 directory (ex: cd src/Chapter01
).
Then use the dotnet run
command to begin the program and follow the prompts for which listing to execute.
Instead of navigating to the chapter directory of the project you want to run, you can use the dotnet run -p <projectfile>
command where project file is the path to the project file you are trying to execute (e.g., dotnet run -p .\src\Chapter01\Chapter01.csproj
). Once executing, the program will prompt for which listing to execute and then proceed with that listing.
Documentation for .NET CLI tools can be found here:
https://docs.microsoft.com/en-us/dotnet/core/tools/
Many of the listings have corresponding unit tests.
In Visual Studio, to execute a test, open the test project and navigate to the test corresponding to the listing you wish to execute. From there, right-click on the test method and choose either Run Tests (Ctrl+R, T) or Debug Tests (Ctrl+R, Ctrl+T). Alternatively, open your Test Explorer window and run some or all of the tests from there (More Information)
In dotnet test, to run all the tests across all projects, run dotnet test
on the command prompt in the root EssentialCSharp directory (the root directory is the one that contains the EssentialCSharp.sln
file). To run the tests for a single project, use the dotnet test command from the project tests directory of the test you are looking execute.
In the source code there are some things that may look different than when you look at the source code in the book. This is because even though the examples in the book come directly from this repository, not all of the code is shown in the book like it is here.
Some helpful things to note:
When you see matching #region INCLUDE
and #endregion INCLUDE
tags in a listing, between these two tags are where the source code that is able to be seen in this book lies.
When there are matching #region EXCLUDE
and #endregion EXCLUDE
tags in a listing, even if these are within two INCLUDE
tags, this section is omitted from being visible in the book and replaced with a // ...
just to try and bring more clarity to the point that is actually being taught in that listing.
In addition, any line that ends with a // EXCLUDE
is a line that is omitted from being seen in the book.
If you have any questions or find any bugs, please feel free to open a Discussion, Pull Request, or Issue.
If there is an issue with EssentialCSharp.com, please checkout the EssentialCSharp.Web Repository