会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
ATP
博客园
首页
新随笔
新文章
联系
管理
订阅
关于静态成员
using
System;
using
System.Collections.Generic;
using
System.Text;
namespace
ConsoleApplication9
{
class
Program
{
static
void
Main(
string
[] args)
{
employee a
=
new
employee();
employee b
=
new
employee();
employee c
=
new
employee();
employee.ShowConut();
}
class
employee
{
public
static
int
conut;
public
employee()
:
this
(
"
li
"
,
"
1
"
)
{
}
public
employee(
string
n,
string
I)
{
Name
=
n;
ID1
=
I;
conut
+=
1
;
}
string
name;
public
string
Name
{
get
{
return
name; }
set
{ name
=
value; }
}
string
ID;
public
string
ID1
{
get
{
return
ID; }
set
{ ID
=
value; }
}
public
void
showname()
{
Console.WriteLine(
this
.name);
}
public
static
void
ShowConut()
{
Console.WriteLine(conut);
}
}
}
}
类中的静态字段或方法只能在程序运行期间实例化一次,上例结果是3
肩负责任,永不退缩
posted on
2007-08-18 10:20
ATP.NET
阅读(
185
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
公告