public void WithNotEmpty()
		{
			var source = new Dictionary<int, string> { { 1, "a" }, { 2, "b" }, { 3, "c" } };
			var result = source.With(2);

			Assert.AreEqual("b", result);
		}
Example #2
0
        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();
        }