更新时间:2023-01-07 16:24:05
没有,你不能。 C#不执行鸭打字。
No, you cannot. C# does not implement duck typing.
您必须实现接口和投给它。
You must implement an interface and cast to it.
(但也有尝试这样做。看的Duck打字项目一个例子。)
(However there are attempts to do it. Look at Duck Typing Project for an example.)
可以将一个变量转换为存储在另一个变量类型?
我可以将一个字段中的数据用作另一个字段中的变量吗?