C # type system

xiaoxiao2021-04-11  1.4K+

The C # 2005 type system contains the following categories:

· Value type

· Quote type

· Pointer type

Value type variable stored data, and the reference type variable stores references to actual data. The reference type is also known as an object. The pointer type is only available for Unsafe mode.

By packing and unpacking, the value type can be converted to a reference type and then convert the value type. In addition to the type of packages, the reference type cannot be converted to a value type.

This section also introduces the Void type.

The value type can also be empty, which means that they can store additions non-value. For more information, see the air type.

Modifiers are used to modify the statement of types and type members. This section introduces C # 2005 modifier:

Modifier

use

Access modifier

PUBLIC

Private

Internal

PROTECTED

Specifies the type of declaration and the accessibility of type members.

Abstract

Indicates that a class can only be the base class of other classes.

Const

Specifies the value that cannot modify the field or partial variable.

Event

Declare event.

Extern

Indicates the external implementation method.

· New

Hide inheritance from the base class member.

Override

Provide new implementation of virtual members inherited from base classes.

Partial

Define branch classes and structures throughout the same app.

Readonly

Declare a field that can only assign a part of the declaration or in the same class constructor.

SeaD

The specified class cannot be inherited.

Static

The declaration belongs to a type itself instead of a member belonging to a specific object.

Unsafe

Declare an unsafe context.

Virtual

Declare its implementation in the derived class or a method or accessor that rewrite member changes.

Volatile

The indicator field can be modified in the program by an operating system, hardware, or concurrent execution thread or the like.

Method parameters If REF or OUT is not used when declared parameters for the method, the parameter can have an associated value. This value can be changed in the method, but the change is not retained when the control is transferred backward call. This behavior can be changed by using method parameters keywords.

This section describes the keywords that can be used when declared methods parameters:

PARAMS

· Ref

OUT

Name Space Keyword This section describes the keywords and operators associated with the using namespace:

· Namespaces

Using

Operator

· :: operator

· External alias

Operator keyword is used to perform miscellaneous operations, such as creating objects, check the runtime type of objects, and get the size of the type, and so on. This section describes the following keywords:

· AS converts objects to compatibility types.

· IS check the runtime type of object.

· New

o NEW operator creates an object.

o New modifier hides inheritance members.

o NEW constraint limit type parameters.

· SIZEOF Get the size of the type.

· TypeOf Get the type of System.Type object.

True

o True operator returns the Boolean True to true, otherwise returns false.

o True represents the Boolean True.

False

o False operator returns the Boolean TRUE to indicate the fake, otherwise returns false.

o False indicates the Boolean value FALSE.

· Stackalloc allocates memory blocks on the stack.

In the statement section, the following can be used as the operator and statement keyword:

Checked specifies the context that has been checked.

· Unchecked specifies the unchecked context.

Conversion Keyword This section describes the keywords used in type conversion:

· Explicit

Implicit

Operator

This section describes the following access key:

· Base

Visit the member of the base class.

· This

Current instance of the class.

C # 2005 has the following text key:

· NULL

True

False

· Default

The context keyword is used to provide specific meanings in the code, but it is not a reserved word in C # 2005. This section describes the following context keywords:

GET defines the accessor method for the attribute or indexer.

Partial defines a partial class, structure, and interface within the entire same compilation unit.

SET defines the accessor method for the attribute or indexer.

WHERE adds constraints to generic declarations.

Yield is used in iterator blocks to end iteration to the enumeration number object return value or signal end iteration.

VALUE is used to set an accessor and add or remove event handler.

转载请注明原文地址:https://www.9cbs.com/read-133549.html

New Post(0)