public void ReturnEmpty() { Dictionary <int, string> source = null; var result = source.Return(2, "d"); Assert.AreEqual("d", result); }
public void ReturnNotEmptyNotContains() { var source = new Dictionary<int, string> { { 1, "a" }, { 2, "b" }, { 3, "c" } }; var result = source.Return(10, "d"); Assert.AreEqual("d", result); }
public void ReturnNotEmptyNotContains() { var source = new Dictionary <int, string> { { 1, "a" }, { 2, "b" }, { 3, "c" } }; var result = source.Return(10, "d"); Assert.AreEqual("d", result); }
static void Main(string[] args) { MonadsForObjects.DoDemo(); var data = new Dictionary<int, string>(); //data.Add(1, "My Name"); //data.With(1).Do(_ => Console.WriteLine($"已找到Key为1的结果:{_}")); data.With(1).Return(_ => $"已找到Key为1的结果:{_}", "未找到Key为1的结果").Do(_ => Console.WriteLine(_)); data.Return(1, _ => { Console.WriteLine("Key1不存在,添加Key1"); _. }) //data.TryWith(1) Console.Read(); }
static void Main(string[] args) { MonadsForObjects.DoDemo(); var data = new Dictionary <int, string>(); //data.Add(1, "My Name"); //data.With(1).Do(_ => Console.WriteLine($"已找到Key为1的结果:{_}")); data.With(1).Return(_ => $"已找到Key为1的结果:{_}", "未找到Key为1的结果").Do(_ => Console.WriteLine(_)); data.Return(1, _ => { Console.WriteLine("Key1不存在,添加Key1"); _. }) //data.TryWith(1) Console.Read(); }