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
    肩负责任,永不退缩
  • 相关阅读:
    metasploit模块功能介绍
    虚拟机端口映射
    linux 双网卡实现
    斯坦福第三课:线性代数回顾(Linear Algebra Review)
    斯坦福第二课:单变量线性回归(Linear Regression with One Variable)
    斯坦福第一课:引言(Introduction)
    机器学习的个人见解----深夜总结
    史上最强机器学习资料------来自个人心血总结-----5星级
    如何学习新的知识----心血总结
    21个必知数据科学面试题和答案
  • 原文地址:https://www.cnblogs.com/ATP/p/860631.html
Copyright © 2011-2022 走看看