反思+林克+类型铸造
我需要将类型转换为最后一行的 (of type)
cbo.DataSource = DirectCast(GetType(RFOPSEntities) _
.GetProperty(entityName & "s") _
.GetGetMethod() _
.Invoke(m_Entities, Nothing), ObjectSet(Of ACAmp)))
.OrderBy(Function(c As ACAmp)) c.SortOrder).ToList()
现在我需要这样做:
cbo.DataSource = DirectCast(GetType(RFOPSEntities) _
.GetProperty(entityName & "s") _
.GetGetMethod() _
.Invoke(m_Entities, Nothing), ObjectSet(Of Type.GetType("ACAmp"))).OrderBy(Function(c As Type.GetType("ACAmp")) c.SortOrder).ToList()
Type.GetType("ACAmp") 不是 goog,但类型可以通过字符串传递。如何 ?
I need to cast the type into the (of type) on last line
cbo.DataSource = DirectCast(GetType(RFOPSEntities) _
.GetProperty(entityName & "s") _
.GetGetMethod() _
.Invoke(m_Entities, Nothing), ObjectSet(Of ACAmp)))
.OrderBy(Function(c As ACAmp)) c.SortOrder).ToList()
Now I need to do semeting like that:
cbo.DataSource = DirectCast(GetType(RFOPSEntities) _
.GetProperty(entityName & "s") _
.GetGetMethod() _
.Invoke(m_Entities, Nothing), ObjectSet(Of Type.GetType("ACAmp"))).OrderBy(Function(c As Type.GetType("ACAmp")) c.SortOrder).ToList()
The Type.GetType("ACAmp") is not goog but the type could be pass by string. How ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你想做的事是不可能的。通用参数 -
(Of XYZ)
- 需要在编译时知道,但GetType("ACAmp")
在运行时执行。What you are trying to do is impossible. Generic parameters -
(Of XYZ)
- need to be known at compile time, butGetType("ACAmp")
is executed at runtime.