且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

是否可以将变量转换为存储在另一个变量中的类型?

更新时间:2023-11-29 09:51:28

不,你不能。 C#不实施鸭式打字

No, you cannot. C# does not implement duck typing.

你必须实现一个接口并强制转换它。

You must implement an interface and cast to it.

(但是有尝试这样做,看看 Duck Typing Project 。)

(However there are attempts to do it. Look at Duck Typing Project for an example.)