C#之类的使用
属性与字段的使用类似iOS
class Class1 {
//字段私有,属性公有
private string _name;
private int _age;
/*control + r -> e 快速创建属性*/
public string Name {
set {
_name = value;
}
get {
return _name;
}
}
public int Age {
set {
_age = value;
}
get {
return _age;
}
}
//构造函数
public Class1(string name, int age) {
this.Name = name;
this.Age = age;
}
public void Function() { Console.WriteLine("姓名{0},年龄{1}",this.Name,this.Age);
}
//析构函数
~Class1(){
}
Text text = new Text() { age = 23 };//对象初始化器 }
基类的虚方法(virtual)可以实现继承重写(override)进而实现多态;
抽象类(abstract)的抽象方法(无方法体)也可以实现继承重写(override)实现多态;
随机推荐
- Java中的经典算法之冒泡排序(Bubble Sort)
Java中的经典算法之冒泡排序(Bubble Sort) 神话丿小王子的博客主页 原理:比较两个相邻的元素,将值大的元素交换至右端. 思路:依次比较相邻的两个数,将小数放在前面,大数放在后面.即在第一 ...
- 从0到1打造直播 App
转自http://dev.qq.com/topic/5811d42e7fd6ec467453bf58 概要 分享内容: 互联网内容载体变迁历程,文字——图片/声音——视频——VR/AR——……..从直 ...
- jQuery Validate 表单验证 — 用户注册简单应用
相信很多coder在表单验证这块都是自己写验证规则的,今天我们用jQuery Validate这款前端验证利器来写一个简单的应用. 可以先把我写的这个小demo运行试下,先睹为快.猛戳链接--> ...
- 【译】Spring 4 @Profile注解示例
前言 译文链接:http://websystique.com/spring/spring-profile-example/ 本文将探索Spring中的@Profile注解,可以实现不同环境(开发.测试 ...
- zabbix 中监控windows 的typepref中的值
监控项:typepref -qx在zabbix中实现: 1.测试zabbix-get 获取数据: /usr/local/zabbix/bin/zabbix_get -s 192.168.1.3 -p1 ...
- spring 事务回滚
1.遇到的问题 当我们一个方法里面有多个数据库保存操作的时候,中间的数据库操作发生的错误.伪代码如下: public method() { Dao1.save(Person1); Dao1.save( ...
- Android Studio导入Project、Module的正确方法
Gradle Project项目.Module模块导入 最近看到网上很多人在抱怨,Android Studio很难导入github上下载下来的一些项目,主要包括: 1.导入就在下载Gradle2.根本 ...
- Spring mvc
1... . 2.spring 的结构图 3.spring mvc 架构 4.Spring mvc 的请求流程 . 文字讲解: request-------->DispatcherServler ...
- [LeetCode] Fizz Buzz 嘶嘶嗡嗡
Write a program that outputs the string representation of numbers from 1 to n. But for multiples of ...
- [LeetCode] Rotate Array 旋转数组
Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array ...