C# study notes–three major characteristics of object-oriented

C# study notes–Three major characteristics of object-oriented C# core Object-oriented–Encapsulation Use programs to abstract the real world (everything is an object) to implement functions through programming. Three major features: encapsulation, inheritance, and polymorphism. Classes and Objects Declaration location: namespace Style: class class name{} Naming: Pascal nomenclature (first letter capitalized) Instantiate object: Create a new object based on the class. Person p=new Person(); Member variable Declared in a class statement block Used to describe the characteristics of objects Can be any variable type No limit on quantity Whether to assign a value is determined according to requirements enum E_SexType { Man, Woman } struct Position{}//Position structure class Pet{}//Pet class //Member variables in the class class Person { public string name=”TonyChang”;//Different from the structure–the initial value can be assigned by default public int age=21; public E_SexType sex; public Person bestFriend;//Different from structures—classes can have member types of the same type (essentially because classes are reference types, but cannot be instantiated, preventing repeated new and falling into an infinite loop) public Position pos; public Pet pet; } Default value for member type: Value type: number is 0, bool type is false Reference type: null View (int type) default value: default(int) Supplement: class is…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索