扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条

publicinterface MyInterface ...{
void doSomething();
}
final String msg = "Hello world!";
MyInterface myInter = new MyInterface() ...{
publicvoid doSomething() ...{
System.out.println(msg);
}
};
myInter.doSomething();
String msg = "Hello world!";
MyDelegate mydele = delegate()
...{
Console.WriteLine(msg);
};
mydele();
String msg = "Hello world!";
MyDelegate mydele = delegate()
...{
msg = “Haha”;
};
mydele();
Console.WriteLine(msg);
MyDelegate mydele = null;
...{
String msg = "Hello world";
mydele = delegate()
...{
Console.WriteLine(msg);
};
msg = "haha";
}
mydele();
class C
...{
public void DoSomething()
...{
Console.WriteLine("Hello world");
}
~C()
...{
Console.WriteLine("finalize");
}
}
private static MyDelegate GetDele()
...{
MyDelegate mydele = null;
...{
C c = new C();
mydele = delegate()
...{
Console.WriteLine("In delegate");
// c.DoSomething();
};
}
return mydele;
}
MyDelegate mydele = GetDele();
//GC.Collect();
mydele();
private static void UseDele()
...{
MyDelegate mydele = GetDele();
GC.Collect();
mydele();
}
UseDele();
GC.Collect();
Console.WriteLine("in Main");
var msg = "hello world";
var myfunc = function()
...{
document.write(msg);
};
myfunc();
MyDelegate mydele = null;
for (int i = 0; i < 2; i++)
...{
String msg = "Hello world!" + i.ToString();
if (i == 0)
mydele += delegate()
...{
Console.WriteLine(msg);
};
}
mydele();
var myfunc = null;
for(var i = 0; i < 2; i++)
...{
var msg = "hello world" + i;
if(i == 0)
myfunc = function()
...{
document.write(msg);
};
}
myfunc();
function GetFunction()
...{
return function()
...{
document.write(msg);
}
}
var myfunc = GetFunction();
var msg = "Hello world";
myfunc();
function GetFunction()
...{
return function()
...{
document.write(msg);
}
}
function Func2()
...{
var myfunc = GetFunction();
var msg = "Hello world1";
myfunc();
}
Func2();
var myfunc = null;
function SetFunc(msg, i)
...{
if(i == 0)
myfunc = function()
...{
document.write(msg);
};
}
for(var i = 0; i < 2; i++)
...{
var msg = "hello world" + i;
SetFunc(msg, i);
}
myfunc();
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。