最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
使用JScript.NET创建asp.net页面(四)
时间:2022-06-30 11:48:41 编辑:袖梨 来源:一聚教程网
在Jscript中定义类通过类声明, 包含方法和对象和var 声明。对于类的派生通过下面两个程序的对比,你讲清楚地明白。
JScript 5.5 Code
// Simple object with no methods
function Car(make, color, year)
{
this.make = make;
this.color = color;
this.year = year;
}
function Car.prototype.GetDescription()
{
return this.year + " " + this.color + " " + this.make;
}
// Create and use a new Car object
var myCar = new Car("Accord", "Maroon", 1984);
print(myCar.GetDescription());
JScript.NET Code
// Wrap the function inside a class statement.
class Car
{
var make : String;
var color : String;
var year : int;
function Car(make, color, year)
{
this.make = make;
this.color = color;
this.year = year;
}
function GetDescription()
{
return this.year + " " + this.color + " " + this.make;
}
}
var myCar = new Car("Accord", "Maroon", 1984);
print(myCar.GetDescription());
Jscript.net还支持定义private和protected property通过GET和SET进行读写。
如下例:
class Person
{
private var m_sName : String;
private var m_iAge : int;
function Person(name : String, age : int)
{
JScript 5.5 Code
// Simple object with no methods
function Car(make, color, year)
{
this.make = make;
this.color = color;
this.year = year;
}
function Car.prototype.GetDescription()
{
return this.year + " " + this.color + " " + this.make;
}
// Create and use a new Car object
var myCar = new Car("Accord", "Maroon", 1984);
print(myCar.GetDescription());
JScript.NET Code
// Wrap the function inside a class statement.
class Car
{
var make : String;
var color : String;
var year : int;
function Car(make, color, year)
{
this.make = make;
this.color = color;
this.year = year;
}
function GetDescription()
{
return this.year + " " + this.color + " " + this.make;
}
}
var myCar = new Car("Accord", "Maroon", 1984);
print(myCar.GetDescription());
Jscript.net还支持定义private和protected property通过GET和SET进行读写。
如下例:
class Person
{
private var m_sName : String;
private var m_iAge : int;
function Person(name : String, age : int)
{
相关文章
- 以下哪种非遗技艺是用针在纸上绣画 蚂蚁新村11月21日答案 11-22
- 江南百景图听风塔怎么样 11-22
- 原神恰斯卡圣遗物怎么搭配 11-22
- 2024年霸王茶姬11月22日口令是什么 2024.11.22霸王茶姬口令介绍 11-22
- 光遇11.21季节蜡烛在哪里 光遇11月21日季节蜡烛位置攻略 11-22
- 光遇11.21大蜡烛在哪里 光遇11月21日大蜡烛位置攻略 11-22