Implement Your Option Wrapper
Implement a lightweight version of the Option type.
We'll cover the following...
We'll cover the following...
So far, we have used the Option type as a replacement for null and C# 8.0 nullable references when working with previous versions of the C# language. Also, we learned that C#, unlike functional languages, doesn’t have a built-in Option type. We have to either use a third-party library or write our own Option type. Let’s write our own lightweight Option type to see its inner workings.
Defining the Option class
Let’s start by writing an Option class with the Some(), ...
Let’s take a look at ...