创建一个只读属性

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 = ;
Employee e1 = new Employee();
e1.Name = "cave";
Console.WriteLine(Employee.Counter);
}
}
}

c#属性1(Property)的更多相关文章

  1. Android属性(property)机制

    1. 属性简介 Android里有很多属性(property),每个属性都有一个名称和值,他们都是字符串格式.这些属性定义了Android系统的一些公共系统属性.比如: [dalvik.vm.dexo ...

  2. Python进阶之“属性(property)”详解

    Python中有一个被称为属性函数(property)的小概念,它可以做一些有用的事情.在这篇文章中,我们将看到如何能做以下几点: 将类方法转换为只读属性 重新实现一个属性的setter和getter ...

  3. Android动画主要包含补间动画(Tween)View Animation、帧动画(Frame)Drawable Animation、以及属性动画Property Animation

    程序运行效果图: Android动画主要包含补间动画(Tween)View Animation.帧动画(Frame)Drawable Animation.以及属性动画Property Animatio ...

  4. Objective-C:属性(@property)

    @import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...

  5. C# 属性(Property)和字段(Field)的区别

    导读: 近期学习过程中发现了一些问题,我的学习只是学习,敲代码就是敲代码,没有加入思考,也不问为什么就直接去敲人家写好的例子去敲,把知识都学死了,逐渐散失了思考能力,所以学习的兴趣大打折扣,正如那句话 ...

  6. 始终使用属性(Property),而不是字段(Data Member)

    1.始终使用属性(Property),而不是字段(Data Member) C# 属性已经晋升为一等公民,如果你的类中还有public的字段,Stop.访问属性和字段的方式是一样的,但是属性是用方法( ...

  7. python基础-abstractmethod、__属性、property、setter、deleter、classmethod、staticmethod

    python基础-abstractmethod.__属性.property.setter.deleter.classmethod.staticmethod

  8. (转)Python内置函数进阶之“属性(property())”详解

    原文:https://blog.csdn.net/GeekLeee/article/details/78519767 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.c ...

  9. js便签笔记(2)——DOM元素的特性(Attribute)和属性(Property)

    1.介绍: 上篇js便签笔记http://www.cnblogs.com/wangfupeng1988/p/3626300.html最后提到了dom元素的Attribute和Property,本文简单 ...

  10. python-静态方法staticmethod、类方法classmethod、属性方法property

    Python的方法主要有3个,即静态方法(staticmethod),类方法(classmethod)和实例方法 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 def  ...

随机推荐

  1. unittest中diascover批量执行用例

    # case_dir='./'#当前脚本的路径 # discover=unittest.defaultTestLoader.discover(case_dir,pattern='unittest_fr ...

  2. iview和element中日期选择器快捷选项的定制控件

      公司的两个vue项目中都用到了iview和element这个框架,最近的两个需求都有关于日期选择的定制控件,就是要求日期选择的快捷选项左边栏有包含今日.昨日.本周.上周.最近一周.本月.上月.上季 ...

  3. ArrayList源码解析(二)

    欢迎转载,转载烦请注明出处,谢谢. https://www.cnblogs.com/sx-wuyj/p/11177257.html 自己学习ArrayList源码的一些心得记录. 继续上一篇,Arra ...

  4. asp.net core mvc中自定义ActionResult

    在GitHub上有个项目,本来是作为自己研究学习.net core的Demo,没想到很多同学在看,还给了很多星,所以觉得应该升成3.0,整理一下,写成博分享给学习.net core的同学们. 项目名称 ...

  5. django1-环境搭建

    我的环境:win10 + pycharm2019.1.3 + python3.6.5 + Django2.1.10 安装django cmd下执行:pip install django==2.1.10 ...

  6. ANSI最全介绍linux终端字体改变颜色等

    ANSI转义序列 维基百科,自由的百科全书 由于国内不能访问wiki而且国内关于ANSI的介绍都是简短的不能达到,不够完整所以转wiki到此博客,方便国内用户参考,原地址(https://zh.wik ...

  7. 【MongoDB详细使用教程】二、MongoDB基本操作

    目录 数据类型 数据库操作 集合操作 数据操作 增 查 改 修改整行 修改指定字段的值 删 数据类型 MongoDB常见类型 说明 Object ID 文档ID String 字符串,最常用,必须是有 ...

  8. LHH的acm奋斗史,至强的精神(转载)

    还记得2年前的一个晚上,我和一个女孩一起写完了这篇文章.写完后,她哭了,我笑了.然后,她走了,我哭了.2年后,我又找到她,这次,我没有让她走掉,她成了我的新娘. 不知道什么时候,开始知道ACM:也不知 ...

  9. python中根据时间获取周数,通过周数获取时间

    # 时间## 时间和周数 import time import datetime # 获取今天是第几周 print(time.strftime('%W')) # 获取当前是周几(0-6,0代表周一) ...

  10. markdown 入门教程(完整版)

    Markdown是一种可以使用普通文本编辑器编写的标记语言,通过简单的标记语法,它可以使普通文本内容具有一定的格式. 1. 标题 Markdown支持6种级别的标题,对应html标签 h1 ~ h6 ...