vb.net - 您可以将 "type"作为参数传递吗?

标签 vb.net casting types

我想在VB.NET中执行以下操作,这可能吗?

Function task(value as Object, toType as Type)

   Return DirectCast(value, toType)

End Function

最佳答案

是的。有System.Type。您实际上可能想做一个泛型。

Function SomeFunction(Of T)(obj As Object) As T
    '' Magic
End Function

关于vb.net - 您可以将 "type"作为参数传递吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1074251/

相关文章:

c# - 在 LINQ to SQL 中搜索两列?

vb.net - 不同环境下的十进制解析差异

Python - 使用 "astype"的 Pandas 列类型转换不起作用

function - 测试 Dart 值是否实际上是一个函数?

jquery - 传递给 MVC Action 的 JSON Date 参数始终为 null

vb.net - 如何将文本文件作为我的构建的一部分?

windows - 如何找到 Word 应用程序窗口?

java - 创建通过反射获得的对象集合

c++ - 我们可以使用 const_cast 将 const vector<string> 转换为 vector<string> 吗?

c - 在 printf 中使用 %d 来打印浮点值会给出意外的输出