Adding unknown (at design time) properties to an ExpandoObject

前端 未结 5 1721
天涯浪人
天涯浪人 2020-11-27 03:35

just exploring c# 4. Trying to get my head around all this dynamic stuff. Sorry if this question is silly, no experience in this domain.

If I have an ExpandoObject a

5条回答
  •  盖世英雄少女心
    2020-11-27 04:17

    It's possible to add delegate properties to an ExpandoObject, which then act (almost) just like methods. e.g.,

    dynamic obj = new ExpandoObject();
    obj.GetDocumentTemplate = () => { ... };
    ...
    obj.GetDocumentTemplate(); // invokes delegate
    

提交回复
热议问题