标签:class void result rri EAP add ogr names get
using ImpromptuInterface; using System; using System.Dynamic; namespace ConsoleApp2 { class Program { static void Main(string[] args) { dynamic expando = new ExpandoObject(); expando.name = "cys"; expando.Add = new Func<int, int>(i=> { return i; }); var expando_result = expando.Add(1); Console.WriteLine(expando.GetType().Name); dynamic dobject = new BB { name="aaa" }; var dobject_result = dobject.ADD(); dobject.Name = "cys"; Console.WriteLine(dobject.Name); Console.WriteLine(dobject.GetType().Name); } } public class BB : DynamicObject { public string name { get; set; } public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result) { result = "a"; return true; } public override bool TryGetMember(GetMemberBinder binder, out object result) { result = name; return true; } public override bool TrySetMember(SetMemberBinder binder, object value) { name = value.ToString(); return true; } } }
ExpandoObject与DynamicObject的使用
标签:class void result rri EAP add ogr names get
原文地址:https://www.cnblogs.com/chenyishi/p/10218296.html