Does something like a VB “Variant” implementation exist which uses C#'s dynamic dispatch?

不羁岁月 提交于 2019-12-06 02:03:44

The visual basic languages hide a lot of the glue, that just isn't the C# way. The Variant type has a raft of conversion functions, they are invoked automatically by the vb runtime. .NET has automatic conversion functions too, you just have to use them explicitly:

dynamic x = 1.0;
int y = Convert.Int32(x);

With the C# justification for having to write code like that because it is not a language that hides cost.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!