国产激情自拍_国产9色视频_丁香花在线电影小说观看 _久久久久国产精品嫩草影院

首頁 > 學院 > 開發(fā)設計 > 正文

C# for Beginner session 21 to 30

2019-11-17 02:39:13
字體:
來源:轉載
供稿:網(wǎng)友

C# for Beginner session 21 to 30

session 21Inheritance in c#

Why Inheritance

Pillars(支架) of Object Oriented PRogramming

1,Inheritance(繼承)

2,Encapsulation(封裝)

3,Abstraction(抽象類)

4,Poymorphism(多態(tài))

1,Inheritance is one of the primary pillars of object oriented programming.

2,It allows code reuse.(重用)

3,Code reuse can reduce time and errors.

Note:You will specify(指定) all the common fields, properties,methods in the base class,which allows reusability.In the derived class you will only have fields, properties and methods,that are specific to them.

Inheritance Syntax

1,using : to inheritance

2,C# supports only single class inheritance.

3,C#supports multiple interface inheritance.

4,Child class is a specialization(特殊化) of base class.

5,Base classes are automatically instantiated(實例化) before derived classes.

6,Parent class constructor executes before Child Class constructor.

7,Using base keyWord to specify which Constructor methods .

session 22 Method hiding in c#

using the new keyword to hide a base class memeber.You will get a compiler(編譯器) warning,if you miss the new keyword.

Different ways to invoke a hidden base class member from derived class

1,Use base keyword.

2,Cast child type to parent type and invoke the hidden member

3,ParentClass PC = new ChildClass()

PC.HiddenMethod()

session 23Polymorphism in c#

Polymorphism is one of the primary pillars of object-oriented programming.

Polymorphism allows you to invoke derived class methods through a base class reference during runtime.

In the base class the method is declared virtual, and in the derived class we override the same method.

The virtual keyword indicates, the method can be overridden in any derived class.

session 24Difference between method overriding and method hiding

In method overriding a base class reference variable pointing to a child class object, will invoke the overriden method in the child class

In method hiding a base class reference variable pointing to a child class object, will invoke the hidden method in the base class.

session 25Method overloading in c#

Function overloading and method overloading terms are used interchangeably(互換).

Method overloading allows a class to have multiple methods with the same name, but, with a different signature(簽名). So, in C# functions can be overloaded based on the number, type(int, float etc), and kind(Value, Ref or Out) of parameters.

The signature of a method consists of the name of the method and the type, kind, and the number of its formal parameters. the signature of a method does not include the return type and the params modifier. So, it is not possible to overload a function, just based on the return type or params modifier.

session 26Why Properties

Marking the class fields public and exposing(暴露) to the external world is bad, as you will not have control over what gets assigned(賦值) and returned.

簡單的說,為了保護數(shù)據(jù)安全和完整性,所以需要屬性。

session 27Properties in C#

In C# to encapsulate(封裝) and protect fields we use properties

1,We use get and set accessors(訪問器) to implement properties

2,A property with only get accessor is a Read only property

3,A property with only set accessor is a Write only property

4,A property with both get and set accessor is Read/Write property

Note:The advantage of properties over traditional(傳統(tǒng)的) Get() and Set() methods is that, you can access(訪問) them as if they were public fields.

Auto implemented Properties

if there is no additional logic in the property accessors, then we can make use of auto implemented properties introduced in C# 3.0

Auto-implemented properties reduce the amount of code that we have to write.

When you use auto-implemented properties, the compiler creates a private, anonymous field that can only be accessed through the property's get and set accessors.

session 28Structs in C#

Structs

Just like calsses structs can have

1,Private Fields

2,Public Properties

3,Constructors

4,Methods

Object initializer syntax(語法), introduced in C# 3.0 can be used to initialize either a struct or a class

session 29Difference between classes and structs in c#

a struct is a value type where as a class is a reference type.(結構是值類型,類是引用類型)

All the differences that are applicable(適用于) to value types and reference types are also applicable to classes and structs

Structs are stored(存儲) on stack(棧), where as classes are stored on the heap(堆).

value type hold their value in memory where they are declared, but reference types hold a reference to an object in memory.

Value types are destroyed(銷毀) immediately(馬上) after the scope(應用范圍,也就是大括號) is lost, where as for reference types only the reference variable(變量) is destroyed after the scope is lost. The object is later destroyed by garbage collector.

when you copy a struct into another struct, a new copy of that struct gets created and modifications on one struct will not affect the values contained by the other struct.

when you copy a class into another class, we only get a copy of the reference variable, both the reference variables point to the same object on the heap. so, Operations on one variable will affect the values contanined by the other reference variable.

Classes Vs Structs

Structs can't have destructors, but classes can have destructors.(結構不能有析構函數(shù),類可以有)

Structs cannot have explicit parameter less constructor where as a class can.(結構不可以有無參構造函數(shù),類可以有)

Struct can't inherit from another class where as a class can. Both structs and classes inherit form an interface.(結構不能繼承類,類可以繼承機構,類和機構都可以繼承接口)

Example of structs in the .NET Framework -int(System.Int32),double(System.Double) etc.

Note1: A class or a struct cannot inherit form another struct. when Struct are sealed stypes.

Note2:How do you prevent a class from being inherited? Or what is the significance of sealed Keyword?

session 30Interfaces in c#

We create interfaces using interface keyword. just like classes interfaces also contains properties, methods, delegates or events, but only declarations and no implementations.

It is a compile time error to privide implementations for any interface member.

Interface members are public by default, and they don't allow explicit(顯式) access modifiers.

Interfaces cannot contain fields.(接口不可以包含字段)

If a class or struct inherits from an interface , it must provide implementation for all interface members. Otherwise, we get a compiler error.

A class or a struct can inherit from more than one interface at the same time, but where as, a class cannot inherit from more than oncee class at the same thime.

Interfaces can inherit from other interfaces. A class that inherits this interface must provide implementation for all interface members in the entire interface inheritance chain(一系列)

We cannot create an instance of an interface, but an interface reference variable can point to a derived class object.(接口不可以實例化,可是接口的引用可以指向子類,例如:IA a = new IA(); 這個是錯的,可是如果類A繼承了接口IA,那么這樣是可以的:IA a = new A();


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
国产激情自拍_国产9色视频_丁香花在线电影小说观看 _久久久久国产精品嫩草影院
精品一二三区视频| 狠狠狠狠狠狠操| 天天操天天操天天色天天要| 激情小说 在线视频| 天堂在线免费观看| 国产成人精品久久一区二区小说| 国产小视频福利在线| 伊人av免费在线观看| 久久国产热视频| 国产日产一区二区| 在线视频中文字幕| 国产亚洲依依| 日本最新在线视频| 在线免费观看污| 丁香六月婷婷| 亚洲网站一区| 国产亚洲精品久久久久久移动网络| 国产www.大片在线| 日本在线观看| 91麻豆福利| 国产精品亚洲第五区在线| 亚洲xxxxxx| 国产第一页在线视频| 国产在线精品一区二区不卡| 一本大道久久精品| 国产午夜三区视频在线| 日本福利午夜视频在线| 国产精品久久麻豆| 亚洲一区二区三区在线观看网站| 日本免费黄色| 亚洲精品在线视频免费| 国产对白在线| 国产黄色小视频| 九九热在线视频免费观看| 羞羞视频在线观看免费| 国产区在线视频| 国产乱妇乱子| 国产麻豆综合视频在线观看| 亚洲伊人网在线观看| av福利在线观看| 精品偷拍激情视频在线观看| 国产写真视频在线观看| 最近中文字幕mv免费高清电影 | 99视频免费| 国产在线看片| 国产中文字幕在线看| 超碰在线中文| 天堂在线一二区| 国产欧美日韩专区| 99视频免费| 国产三级视频在线看| 成在在线免费视频| 国产裸舞福利在线视频合集| 国产免费人人看| 国产视频三区| 精品一区二区在线欧美| 福利视频网站导航| 国产香蕉视频在线看| 国产经典av| 在线免费看av| 国产乱子伦三级在线播放| 中文字幕日本在线观看| 2021天堂中文幕一二区在线观| 在线免费看黄网站| 国产男女无套在线播放| 国产videos| 国产嫩草在线视频| 一本大道香蕉久久| 最近中文字幕mv2018在线高清 | 香蕉视频在线看| 欧美精品另类| 国产精品久久人| 日本电影全部在线观看网站视频| 国产毛片在线看| 亚洲图区综合| 国产馆av播放| 欧美视频免费一区二区三区| 国产在线资源| 一本大道久久精品| 国产xxx在线| 中文字幕在线资源| 国产日韩欧美精品一区二区三区| www.91av| 99精品老司机免费视频| 国产精品综合久久久久| 欧美亚洲另类在线观看| 在线观看电影av| 国产福利视频在线观看| 日本中文字幕在线观看| 亚洲va国产日韩欧美精品色婷婷| 国产写真视频在线观看| 高潮白浆视频| 丁香花在线电影| 国产尤物视频在线| 国产免费电影网站入口| 国产免费高清| 日本精品一区二区三区在线播放| 国产变态拳头交视频一区二区| 91av久久| 国产美女免费观看| 国产在线三区| 丁香视频免费观看| 国产免费av在线| 尤物视频在线观看| 中文字幕乱在线伦视频乱在线伦视频| 久热中文字幕精品视频在线| 久久久久久国产视频| 狠狠干在线视频| 中文字幕免费中文| 国产婷婷视频在线| 国产精品麻豆一区二区三区| 狠狠插狠狠操| 国产网站麻豆精品视频| 国产精品69一区二区三区| 国产高清视频在线播放| 97人人在线| 日本久久国产| 国产一级在线观看| 69免费视频| 九九热视频在线观看| 国产三级视频在线播放线观看| 中文日本在线观看| 欧美精品久久久久久久小说| 国产中文伊人| 2020国产在线视频| 免费电影网站在线视频观看福利| 伊人影院在线视频| 国产美女被草| 在线视频中文字幕第一页| 黄色av免费看| av免费在线观| 国产视频你懂的| 亚洲欧美综合乱码精品成人网| 福利视频网址导航| av网站在线播放| 国产一起色一起爱| 狠狠综合久久久综合| 国产高清视频在线观看| www.eeuss影院| 6699久久国产精品免费| 国产毛片在线| 中文岛国精品亚洲一区| 午夜伦全在线观看| 超碰在线人人| jizz在线视频| 中文字幕av在线| 国产日韩欧美一区二区三区视频| av在线不卡免费| 精品av中文字幕在线毛片| 国产香蕉视频在线观看| 狠狠干婷婷色| 久久久久久国产视频| 香蕉视频在线观看网站| 99高清免费国产自产拍| 国产99在线|亚洲| 国产激情视频网址| 国产在线色视频| 福利视频在线看| 国产麻豆免费| 国产精选一区二区三区不卡催乳| 牛牛精品视频在线| 青青国产在线| 欧美精品另类| 成网站在线观看人免费| 国产美女福利在线观看| 国产精品自拍在线观看| 国产老肥熟xxxx在线观看| 国产69久久| 中文字幕在线观看播放| 国产精品欧美韩国日本久久| 国产精品入口麻豆高清| 国产一区二区影视| 国产三级在线播放| 在线一区观看| 黄色av电影在线播放| 国产无遮挡在线视频免费观看| 中文字幕高清av| 777电影在线观看| 午夜影院在线| 午夜av在线播放| 99爱在线观看| 国内自拍视频在线看免费观看| 黄色av网站在线免费观看| 国产日韩欧美一区二区三区视频| 精品三级久久久久久久电影聊斋| 在线中文字幕资源| 亚洲精品影院在线| 久久精品免视着国产成人| 国产精品爱久久久久久久小说 | 国产另类图片| 亚洲免费网站在线观看| 国产在线三区| 夜夜操天天干| 国产午夜视频在线观看| 亚洲人在线播放| 国产高清视频在线| 国产精品一区二三区| 国产三级做爰在线观看| 男人天堂亚洲| 亚洲欧美日韩综合精品网|