说我有这样的事情:
string singleStatement = "System.DateTime.Now";
Run Code Online (Sandbox Code Playgroud)
有没有办法singleStatement在运行时采取和解析并运行它?
以便:
DateTime currentTime = singleStatement.SomeCoolMethodToRunTheText();
Run Code Online (Sandbox Code Playgroud)
会指定DateTime.Nowto 的值currentTime.
这只有通过使用编译器服务才能实现,编译器服务Reflection.Emit()将进行编译、汇编并加载到内存中。
看看这里。
http://www.c-sharpcorner.com/UploadFile/puranindia/419/
| 归档时间: |
|
| 查看次数: |
47492 次 |
| 最近记录: |