zoukankan      html  css  js  c++  java
  • c#属性1(Property)

    创建一个只读属性

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Globalization;
    using System.Linq;
    using System.Text;
    using 编码练习;
    
    namespace 编码练习
    {
        //创建类people,里面有两个属性
        public class Employee
        {
            public static int NumberOfEmployees;
            private static int counter;
            private string name;
    
            // A read-write instance property:
            public string Name
            {
                get { return name; }
                set { name = value; }
            }
    
            // A read-only static property:
            public static int Counter
            {
                get { return counter; }
            }
    
            // A Constructor:
            public Employee()
            {
                // Calculate the employee's number:
                counter = ++NumberOfEmployees;
            }
        }
    }
    public class SerchPeople
    {
        public static void Main()
        {
            Employee.NumberOfEmployees = 107;
            Employee e1 = new Employee();
            e1.Name = "cave";
            Console.WriteLine(Employee.Counter);
        }
    }
    }
  • 相关阅读:
    PHP CI分页类带多个参数
    PHP oracle分页
    PHP 防范IP攻击
    PHP 防范CC攻击
    PHP 防范xss攻击
    html input
    弹框样式
    php最快捷的插入数据,3000万仅需5秒
    phpcms 后台分页
    phpcms 用phpexcel导入导出excel
  • 原文地址:https://www.cnblogs.com/jestin/p/11535036.html
Copyright © 2011-2022 走看看