将字符串值转换为方法
问题描述:
大家好,需要你的启发,因为我是vb.net的新手。
Hi All, need your enlightenment since i was new in vb.net.
'this value is a string type
varsfromDB = Dataset.Tables(0).Rows(I)("FUNC")
'this part that i did not know how to make the next line to work
varsConverted = convert.sometype(varsfromDB)
'this line is the goal
Call varsConverted()
并且它肯定以表达式不是方法结束。有人能帮助我吗?
提前谢谢
and it was definitely end up with "expression is not a method". can somebody help me?
thank you in advance
答
这不是你动态调用方法的方式。
你做什么是用反射。
一些例子 -
http://msdn.microsoft.com/en-us/library/a89hcwhh%28v=vs.110%29.aspx [ ^ ]
使用参数名称通过反射调用方法? [ ^ ]
This is not how you call a method dynamically.
What you do is use Reflection.
Some examples -
http://msdn.microsoft.com/en-us/library/a89hcwhh%28v=vs.110%29.aspx[^]
Invoking a method via reflection using parameter names?[^]
您是否在寻找: http://msdn.microsoft.com/en-us/library/system.co nvert.tostring.aspx [ ^ ]?
Are you looking for this : http://msdn.microsoft.com/en-us/library/system.convert.tostring.aspx[^] ?