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 的接口类型用于定义一组行为,其中每个行为都由一个方法声明表示. 接口类型中的方法声明只有方法签名而没有方法实体,而方法签名包括且仅包括方法的名称.参数列表和结果列表. 只要一种数据类型的方法集合 ...
随机推荐
- [Objective-C语言教程]类和对象(24)
Objective-C编程语言的主要目的是为C编程语言添加面向对象,类是Objective-C的核心特性,支持面向对象编程,通常称为用户定义类型. 类用于指定对象的形式,它将数据表示和方法组合在一起, ...
- scrapy实战1,基础知识回顾和虚拟环境准备
视频地址 https://coding.imooc.com/learn/list/92.html 一. 基础知识回顾 1. 正则表达式 1)贪婪匹配,非贪婪匹配 .*? 非贪婪 . ...
- 前端IDE:VSCode + WebStorm
VSCode 插件安装 官网:Extensions for the Visual Studio family of products: (1)拼接下载链接: https://${publisher}. ...
- Java_多线程
线程(Thread) 1.线程是CPU进行资源调度的最小单位 2.线程是进程实际运行的单位,处理进程中无数的小任务 3.线程共享代码和数据空间 4.一个进程可以并发多个线程,线程之间切换系统开销很小 ...
- 论文笔记:CNN经典结构2(WideResNet,FractalNet,DenseNet,ResNeXt,DPN,SENet)
前言 在论文笔记:CNN经典结构1中主要讲了2012-2015年的一些经典CNN结构.本文主要讲解2016-2017年的一些经典CNN结构. CIFAR和SVHN上,DenseNet-BC优于ResN ...
- 能够放在文档的 <head> 中的各种配置元素
一份关于任何可以写入到你的文档中 <head> 部分的清单 最小推荐 <meta charset="utf-8"> <meta http-equiv= ...
- Google Spanner vs Amazon Aurora: Who’ll Get the Enterprise?
https://www.clustrix.com/bettersql/spanner-vs-aurora/ Google Spanner versus Amazon Aurora In July 20 ...
- 【实战】某项目SQL注入引发的思考
数据包: 测试参数:username,测试payload: ' ' or '1'='1 ' or '1'='2 响应结果都未发生任何变化,借助sqlmap测试,结果一样: 尝试在or前面进行简单的fu ...
- mysql数据库基本知识
一.库操作 创建数据库:creat database 'mydababase1';creat database if not exists 'mydababase1' //只有两个选项 查询数据库: ...
- PHP-GD库开发手记
创建带有alpha通道的背景输出图像画中文字体获取长宽等比例缩放图片,也可以用于裁切实例代码 创建带有alpha通道的背景 $png = imagecreatetruecolor(800, 600); ...