我应该将一些代码从VB转换为C#.给出以下VB工作行(我认为仅因为选项未设置为严格): Dim someProp As SomeTypeTry someProp = CType(SomeInstance, Object).SomeProp ' ... 由于后期绑定,这个代码在VB下是可能
Dim someProp As SomeType Try someProp = CType(SomeInstance, Object).SomeProp ' ...
由于后期绑定,这个代码在VB下是可能的.当然,以下内容不适用于C#:
SomeType someProp; try { someProp = ((object)SomeInstance).SomeProp; // ...
我怎么能在C#下制定类似的东西呢?
任何tipps的Thx
sl3dg3
SomeType someProp; try { someProp = ((dynamic)SomeInstance).SomeProp; // ...