-- 作者:admin
-- 发布时间:11/9/2004 2:25:00 AM
-- Introduction to JScript.NET
发信人: zillion (心诚则灵), 信区: DotNET 标 题: Introduction to JScript.NET 发信站: BBS 水木清华站 (Sun May 6 20:21:34 2001) http://www.c-sharpcorner.com/JScript/IntroductionToJScript.asp Submitted By Manish B Mehta We have been hearing the announcement from Microsoft right from PDC2000 that they have realsed new languages viz. C#, VB.NET and JScript.NET This artice of mine is going to introduce to u JScript.NET Jscript's association with the ECMAScript standard has helped its success considerably, this has led to a close compatibality with JavaScript. The most dramatic impact on performance in JScript.NET is that it is a true compiled language, which makes it possible to achieve performance comparable to that of C# and Visual Basic.NET. As JScript is a part of .NET it automatically benefits from all the goodies .NET offers. .NET ships with a compiler for JScript.NET called jsc Jscript can be compiled as a .exe or a .dll (default), Jscript can also be used in ASP.NET pages and create web services by specifying "Language=JScript". Creating a Simple .exe using JScript Hello.js //Copy this line in a file Hello.js //Compile it as jsc /exe Hello.js to produce Hello.exe print("Hello From Jscript Exe"); Creating a Simple Class in Jscript : Class.js //Copy in a file Class.js //Compile it as jsc /exe class.js to produce class.exe class Class1 { function sayHi() { return "Hi from JScript Class"; } } var o : Class1 = new Class1; print(o.sayHi()); A Bit of OOPS in JScript.NET : class1.js //Copy in a file Class1.js //Compile it as jsc /exe Class1.js to produce class1.exe class Class1 { function sayHi() { return "Hi from JScript Class"; } } class c2 extends Class1 { protected var name : String; //variable of type string function get fname() : String //property get (acessor) { return this.name; } function set fname(newName : String) //property let (mutator) { this.name = newName; } } var o : c2 = new c2; print(o.sayHi()); o.fname = "Manish"; print(o.fname); Creating a Simple WebService in JScript.NET : JSweb.asmx <%@ WebService Language ="JScript" Class="MyJS" % > import System.Web.Services; class MyJS extends WebService { WebMethodAttribute function sayHi() : String { return "Hi from a JScript.NET web service"; } } JScript.NET blends seemlessly in the .NET framwework and so will other languages like SmallTalk, FujitsuCOBOL and other .NET compatible languages. -- Since there's no help, Come let us kiss and part. ※ 来源:·BBS 水木清华站 smth.org·[FROM: 211.100.73.91] 上一篇 返回上一页 回到目录 回到页首
|