Skip to content

jeremybytes/nullability-in-csharp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nullability in C#

This repository contains sample code for an upcoming series of articles about nullability, nullable reference types, and the various null operators in C# (null conditional, null coalescing, and null forgiving).


Articles

Links will be added as the articles are completed.


Sample Code

The sample code is take from the resources for "I'll Get Back to You: Task, Await, and Asynchronous Methods in C#" (Repository: using-task-dotnet6).

The "StartingCode" folder contains the original code without null checks or nullability enabled.

The "FinishedCode" folder contains the completed code with nullability enabled as well as null checks and various uses of the null operators.


Running the Application

If you would like to follow along with the code and steps shown in the articles, you can run the sample application with the following:

The .NET service must be started before the main application can be run. One way is to start the service from the command line and then leave it running while debugging the main application in Visual Studio.

To start the service from the command line, navigate to the ".../People.Service" directory and type dotnet run. This provides endpoint at the following location:

[{"id":1,"givenName":"John","familyName":"Koenig","startDate":"1975-10-17T00:00:00-07:00","rating":6,"formatString":null},  
{"id":2,"givenName":"Dylan","familyName":"Hunt","startDate":"2000-10-02T00:00:00-07:00","rating":8,"formatString":null}, 
{...}]

With the service running, you can run the desktop application (UsingTask.UI) from Visual Studio by pressing F5 (or using the menu or toolbar) to start debugging.


Relevant Files

The following lists the relevant files where you can find the code used in the articles.

Project Files

Code Files


About

Sample code for article series on nullability, nullable reference types, and null operators in C#

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages