Created
May 31, 2025 23:19
-
-
Save DoubleCouponDay/22da94f3138f55456e6c3a9a5cfdee15 to your computer and use it in GitHub Desktop.
C# Option<T>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class Option<TValue> where TValue : struct | |
| { | |
| protected TValue? value; | |
| } | |
| public class Some<TValue> : Option<TValue> where TValue : struct { | |
| public TValue Value => value.Value; | |
| public Some(TValue input) | |
| { | |
| value = input; | |
| } | |
| } | |
| public class None<TValue> : Option<TValue> where TValue : struct | |
| { | |
| public None() { } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment