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#学习笔记-接口与抽象类的更多相关文章

  1. java设计模式学习笔记--接口隔离原则

    接口隔离原则简述 客户端不应该依赖它不需要的接口,即一个类对另一个类的依赖应建立在最小的接口上 应用场景 如下UML图 类A通过接口Interface1依赖类B,类C通过接口Interface1依赖类 ...

  2. Java编程思想学习笔记——接口

    1.抽象类和抽象方法 抽象方法:不完整的,仅有声明而没有方法体. abstract void f(); 抽象类:包含抽象方法的类.(若一个类包含一个或多个抽象方法,则该类必须限定为抽象的.) 1.用抽 ...

  3. JAVA学习笔记--接口

    一.抽象类和抽象方法 在谈论接口之前,我们先了解一下抽象类和抽象方法.我们知道,在继承结构中,越往下继承,类会变得越来越明确和具体,而往上回溯,越往上,类会变得越抽象和通用.我们有时候可能会需要这样一 ...

  4. java基础学习笔记五(抽象类)

    java基础学习总结——抽象类 抽象类介绍

  5. 《JAVA学习笔记(14-10---14-11抽象类)》

    [14-10]面向对象-抽象类的产生 /* 描述狗,行为,吼叫. 描述狼,行为,吼叫. 发现他们之间有共性,可以进行向上抽取. 当然是抽取他们的所属共性类型,犬科. 犬科这类事物,都具备吼叫行为,但是 ...

  6. openrisc 之 Wishbone总线学习笔记——接口信号定义

    这部分内容就是copy下来的,网上到处都有.先看看接口啥样子,在详细说明 接口定义copy http://blog.csdn.net/ce123/article/details/6929897.百度文 ...

  7. 【学习笔记】C# 抽象类

    抽象类 有时设计类仅仅为了表达抽象的概念,不与具体的事物相联系,只作为其派生类的基类使用,用来描述所有子类的共同特性,这时我们可以使用抽象类 抽象类不能被实例化,抽象类可以包含抽象方法 抽象方法 抽象 ...

  8. C#图解教程学习笔记——接口

    一.接口概念接口是指定一组函数成员而不实现它们的引用类型.所以只能类和结构来实现接口. 二.声明接口1. 接口声明不能包含:数据成员.静态成员,只能包含以下类型的非静态成员函数:方法.属性.事件.索引 ...

  9. golang学习笔记--接口

    go 的接口类型用于定义一组行为,其中每个行为都由一个方法声明表示. 接口类型中的方法声明只有方法签名而没有方法实体,而方法签名包括且仅包括方法的名称.参数列表和结果列表. 只要一种数据类型的方法集合 ...

随机推荐

  1. [JS] 瀑布流加载

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name ...

  2. 【JavaScript】动态原型模式创建对象 ||为何不能用字面量创建原型对象?

    var proto = ""; function Person(name, age, job) { this.name = name; this.age = age; this.j ...

  3. JavaIO系统

    为了方便记忆,特将IO中涉及的类进行整理如下: 1.File类 提供了目录操作,查看文件属性等. 2.java IO类层次 面向字节流的类为InputStream.OutputStream:面向字符流 ...

  4. CF1139D Steps to One 题解【莫比乌斯反演】【枚举】【DP】

    反演套 DP 的好题(不用反演貌似也能做 Description Vivek initially has an empty array \(a\) and some integer constant ...

  5. hiho# 1394最小路径覆盖 网络流拆点

    题目传送门 思路: 观察到路径上除了终点起点以外的每个点出度和入度都为1,和网络流的拆点很像,所以就把每个点都拆成两个点,若存在一条路径$(u,v)$,则建一条$(u,v+n,1)$的边,然后求出最大 ...

  6. 让 Linux grep 的输出不换行

    在Redhat中亲测. 本来ps -ef的输出是不会换行的,但是 ps -ef | grep java 就换行了. 如果想让grep完的结果不要换行,找到两种方法. 1. 在后面拼接 less -S: ...

  7. follow up2-20190426

    406. Minimum Size Subarray 同向双指针 https://www.lintcode.com/problem/minimum-size-subarray-sum/descript ...

  8. mono for android生成APK出现错误fatal error in gc 解决方案

    laxknight 标签: mono for android,fatal error in gc mono for android生成APK出现这个错误fatal error in gc collec ...

  9. springboot项目:Redis分布式锁的使用(模拟秒杀系统)

    模拟秒杀系统: 第一步:编写Service package com.payease.service; /** * liuxiaoming * 2017-12-14 */ public interfac ...

  10. Git提交项目到GitHub

    一.GitHub新建项目 1.进入Github首页,点击New repository新建一个项目 2.填写相应信息后点击create即可 Repository name: 仓库名称 Descripti ...