C#学习笔记-接口与抽象类
namespace ClassLesson
{
class Program
{
static void Main(string[] args)
{
var person = new Person();
Console.WriteLine(person.GetAge());
Console.WriteLine(Person.getFive()); //static
Console.WriteLine(person.Age);
person.Age = ;
Console.WriteLine(person.Age);
Console.WriteLine(person.Age2);
person.Age2 = ;
Console.WriteLine(person.GetAge());
Console.WriteLine(person.GetName()); Console.ReadLine();
}
} //the default modifier is internal,can be accessed in the namespace
//the Class can only inherit one Class,but can inherit a great deal of Interface
class Person : Main, ISuper
{
int age; public int Age //default value is 0
{
get;
set;
} public int Age2
{
get
{
return age + ;
}
set
{
age = value - ;
}
} public Person(int myAge) //constructed function
{
this.age = myAge;
} public int GetAge() //the default modifier is private (in the Class)
{
return age;
} public static int getFive() //static method be stored in the Class
{
return ;
} public int GetSuper()
{
return age = ;
} public override int GetAbstract()
{
return ;
}
} interface ISuper //only include method、property、index and event
{
int GetSuper(); //only need statement,the details in the Class
} //abstract class=>can't be instantiated
//function:be inherited by other Class
abstract class Main
{
public string Name;
public string GetName()
{
return Name = "string";
} public abstract int GetAbstract(); //abstract method's details must be in the Class which inherited this
} /**
* the difference between Abstract Class and Interface:
* 1.
* Internal:all details be in the Class which inherited it
* Abstract Class:only 'abstract' details be in the Class which inherited it
* 2.
* Internal:can't have member variables and properties
* Abstract Class:all
* 3.
* Abstract Class:can't be instantiated
*
* the Class can only inherit one Class,but can inherit a great deal of Interface
*/
}
C#学习笔记-接口与抽象类的更多相关文章
- java设计模式学习笔记--接口隔离原则
接口隔离原则简述 客户端不应该依赖它不需要的接口,即一个类对另一个类的依赖应建立在最小的接口上 应用场景 如下UML图 类A通过接口Interface1依赖类B,类C通过接口Interface1依赖类 ...
- Java编程思想学习笔记——接口
1.抽象类和抽象方法 抽象方法:不完整的,仅有声明而没有方法体. abstract void f(); 抽象类:包含抽象方法的类.(若一个类包含一个或多个抽象方法,则该类必须限定为抽象的.) 1.用抽 ...
- JAVA学习笔记--接口
一.抽象类和抽象方法 在谈论接口之前,我们先了解一下抽象类和抽象方法.我们知道,在继承结构中,越往下继承,类会变得越来越明确和具体,而往上回溯,越往上,类会变得越抽象和通用.我们有时候可能会需要这样一 ...
- java基础学习笔记五(抽象类)
java基础学习总结——抽象类 抽象类介绍
- 《JAVA学习笔记(14-10---14-11抽象类)》
[14-10]面向对象-抽象类的产生 /* 描述狗,行为,吼叫. 描述狼,行为,吼叫. 发现他们之间有共性,可以进行向上抽取. 当然是抽取他们的所属共性类型,犬科. 犬科这类事物,都具备吼叫行为,但是 ...
- openrisc 之 Wishbone总线学习笔记——接口信号定义
这部分内容就是copy下来的,网上到处都有.先看看接口啥样子,在详细说明 接口定义copy http://blog.csdn.net/ce123/article/details/6929897.百度文 ...
- 【学习笔记】C# 抽象类
抽象类 有时设计类仅仅为了表达抽象的概念,不与具体的事物相联系,只作为其派生类的基类使用,用来描述所有子类的共同特性,这时我们可以使用抽象类 抽象类不能被实例化,抽象类可以包含抽象方法 抽象方法 抽象 ...
- C#图解教程学习笔记——接口
一.接口概念接口是指定一组函数成员而不实现它们的引用类型.所以只能类和结构来实现接口. 二.声明接口1. 接口声明不能包含:数据成员.静态成员,只能包含以下类型的非静态成员函数:方法.属性.事件.索引 ...
- golang学习笔记--接口
go 的接口类型用于定义一组行为,其中每个行为都由一个方法声明表示. 接口类型中的方法声明只有方法签名而没有方法实体,而方法签名包括且仅包括方法的名称.参数列表和结果列表. 只要一种数据类型的方法集合 ...
随机推荐
- 考试题 T1
题意分析 就是让你求 \[\sum_{i=1}^{|S|}val[i][gcd(a[i],x)=y]\] 那么接下来就是化简式子 \[\sum_{i=1}^{|S|}val[i][gcd(\frac{ ...
- jpetStore 学习总结(1)
最近学习了Springmvc4,对官方的例子jpetStore进行了分析研究,在官方网站下载spring-framework-2.5.6.SEC03,其中samples文件夹里就有jpetstore的 ...
- vim中常用的命令
1.光标的命令 gg 移到第一行位置 G 移到最后一行 o 行首 $ 行末 nk 向上移动n行 nj 向下移动n行 nh 向左移动n列 nl 向右移动n列 ctrl+f ...
- find查找文件命令 - Linux系统中的常用技巧整理
“find”在Linux系统中是比较常用的文件查找命令,使用方法有很多,可以拥有查找文件.文件目录.文件更新时间.文件大小.文件权限及对比文件时间.下面是整理的“find”常用方法,方便以后需要的时候 ...
- python全栈开发_day15_模块学习
一:模块 1)什么是模块 每一个py文件就是一个模块 导入模块,会编译执行 1.形成一个对应的pyc文件 2.产生该模块自己的店全局名称空间 3.在使用该模块的全局名称空间中产生一个名字(导入的模块名 ...
- 使用二叉搜索树实现一个简单的Map
之前看了刘新宇大大的<算法新解>有了点收获,闲来无事,便写了一个二叉搜索树实现的Map类. java的Map接口有很多不想要的方法,自己定义了一个 public interface IMa ...
- Monkey and Banana
Monkey and BananaTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- 毫秒查询9位数qq号码是否存在-BitMap算法应用
实现详情请查看博客园 https://www.cnblogs.com/caoke/p/10793885.html 随机注册10万个放入BitMap,然后查询qq号码是否已存在,算法复杂度O(1). / ...
- Compile git version inside go binary
Compile git version inside go binary Abstract 在我们编写的程序中总是希望可以直接查阅程序的版本,通过--version参数就会输出如下版本信息. Buil ...
- Mac下使用Wine安装文件内容搜索工具Search and Replace
下载: (链接: https://pan.baidu.com/s/1mij7WX6 密码: xsu8) 安装: 1.安装Wine 参考:http://www.cnblogs.com/EasonJim/ ...