开发者

Can I use .NET classes from JScript.NET without import statement?

How can I use classes without having to import the namespace in JScript.NET?

E.g. I want to be able to write System.Windows.Forms.MessageBox.Show("Ping"); instead of:

import System.W开发者_高级运维indows.Forms;
MessageBox.Show("Ping");

Is there a way to do this in JScript.NET?


@Anon suggested using WScript.Shell instead of System.Windows.Forms.MessageBox.Show. I think what s/he was trying to communicate is that, if you are after a one-liner, you're not going to get it using assembly notation. However, if you're willing to hook into ActiveX, then a one-liner equivalent is as follows:

(new ActiveXObject("WScript.Shell")).Popup('Ping');

BTW, I have been fiddling for a while, trying to get a pure .NET solution figured out, but so far it has eluded me.

And, if this page about ASP.NET is anything to go by, it should probably be assumed that JScript.NET does NOT automatically import a large swathe of namespaces.


var WshShell = new ActiveXObject("WScript.Shell");

WshShell.Popup(Text, WaitSeconds, Title, Type);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜