Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
鉴于财产:
Func<dynamic,object> Format { set; get; }
还有一个方法参数:
void SomeMethod(Func<T, object> format) { // Set Format here.. }
在此方法中,我将如何设置 Format 属性?
创建一个接受动态对象的新函数,将其转换为您需要的对象,然后将该值传递给您拥有的更具体的函数:
Format = dyn => format((T)dyn);