From 1c4ec8c5070cbed488bf5891122f28c2671291d3 Mon Sep 17 00:00:00 2001 From: Pim Brouwers Date: Fri, 30 Aug 2024 14:04:02 -0400 Subject: [PATCH] console sample --- samples/Console/Program.cs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 samples/Console/Program.cs diff --git a/samples/Console/Program.cs b/samples/Console/Program.cs new file mode 100644 index 0000000..c4352aa --- /dev/null +++ b/samples/Console/Program.cs @@ -0,0 +1,26 @@ +using Danom; + +public static class OptionSamples +{ + private static readonly IEnumerable _store = Enumerable.Range(1, 100); + + public static Option TryFindInt(Func predicate) => + _store.FirstOrDefault(predicate).ToOption(); + + public static void Test() + { + if (Option.Some(1).DefaultValue(1) == 1) + { + Console.WriteLine("Some"); + } + } +} + +// write main method +public static class Program +{ + public static void Main() + { + OptionSamples.Test(); + } +}