zoukankan      html  css  js  c++  java
  • 关于静态成员

    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
    肩负责任,永不退缩
  • 相关阅读:
    关于页面的已终止操作
    Assembly Manifest 通俗简易手册
    C# Enumeration 使用
    打架必备!擒敌拳116动连贯动作 分解动作
    解决js中onMouseOut事件冒泡的问题
    DOM标准与IE的html元素事件模型区别
    vim编辑器
    linux常用的命令解释
    搭建本地仓库
    Linux系统虚拟机安装
  • 原文地址:https://www.cnblogs.com/ATP/p/860631.html
Copyright © 2011-2022 走看看