June 21, 2002 - Delimiting the Main Code
June 21, 2002 Delimiting the Main Code Tips: June 2002
Yehuda Shiran, Ph.D.
|
Main()
or main()
. JScript .NET (as well as JavaScript) is different. The main code in JScript .NET is not delimited in any way. You just write the code outside; before, after, or in between the class definitions. Here is an example that includes two class definitions followed by the main code section:
// compile with: jsc inheritance.js
class Base {
protected var i : int = 5;
public function PrintInBase() : void {
print("i is " + i);
}
}
class Derived extends Base {
var d : double = 7.3;
public function PrintInDerived() : void {
print("i is " + i + ", d is " + d);
}
}
var b : Base = new Base();
print("b:");
b.PrintInBase();
var d : Derived = new Derived();
print("d:");
d.PrintInBase();
d.PrintInDerived();
To learn more about JScript .NET, go to Column 111, JScript .NET, Part V: Polymorphism.