For example, the following code initializes the variable mydate to a test date or the current date, depending on the value of the doTest variable:var doTest : boolean = true;
var dateFn : String;
if(doTest)
dateFn = "Date(1971,3,8)";
else
dateFn = "Date()";var mydate : Date;
eval("mydate = new "+dateFn+";");
print(mydate);The output of this program is:Thu Apr 8 00:00:00 PDT 1971
var dateFn : String;
if(doTest)
dateFn = "Date(1971,3,8)";
else
dateFn = "Date()";var mydate : Date;
eval("mydate = new "+dateFn+";");
print(mydate);The output of this program is:Thu Apr 8 00:00:00 PDT 1971
解决方案 »
- 请问大家平时是怎样为工具栏添加图标的?用的是哪种方式?
- c#怎么判断本机是不是已经上网了
- NetAdvantage控件怎么添加到VS 2008中
- 哪里有C#的视频教程!小弟想学习一下
- Nhibernate支持.net framework 4.0么?
- 在线求助,datagrid控件
- 关于c# 中的FileSystemWatcher事件触发问题,从一个文件夹复制到另一文件夹,只让其触发一次新建OnCreate避免同时触发OnChanged
- C# 下面这行代码如果没有装Microsoft Office 2007 为什么会报错,然而装了的话就可以正常运行,求解释。谢谢
- 如何对比两个DataTable,取相同行!
- SqlConnection与OleDbConnection谁的连接速度快?
- 有效性验证中,某个元素既是必填项目,又要符合一定的规则,如何加验证控件?
- 大家看看是不是c#中的构造函数允许执行虚函数造成的后果?
可以用reflection/CodeDom自己实现。
http://www.codeproject.com/csharp/runtime_eval.asp