Skip to content

Instantly share code, notes, and snippets.

@DoubleCouponDay
Created May 31, 2025 23:19
Show Gist options
  • Select an option

  • Save DoubleCouponDay/22da94f3138f55456e6c3a9a5cfdee15 to your computer and use it in GitHub Desktop.

Select an option

Save DoubleCouponDay/22da94f3138f55456e6c3a9a5cfdee15 to your computer and use it in GitHub Desktop.
C# Option<T>
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