Analysis of Type System (Value Type and Reference Type) in C

  • 2021-12-05 07:07:12
  • OfStack

What I want to write today is all some conceptual things in the book. Just copy notes and write them out in the way of asking questions and dialogues. Maybe I can talk about them in the interview in the future.

What are the three features of the Q 1. C # 1 system type?

The A 1. C # 1 type system is static, explicit, and secure.

Q2. Why is it called static type?

A2. Static type is used to describe the type of expression at compile time. When declaring a variable of type 1, you cannot point the variable to an object of other types.

Q3. What is the difference between an explicit type and an implicit type?

A3. Explicit and implicit types are meaningful only to languages in static types. An explicit type requires an explicit declaration of the type of a variable, while an implicit type puts the responsibility for determining the type on the compiler, but at compile time, the type of the variable is known.

Q4. Value type and reference type, respectively, the following class, structure, array type, enumeration, delegate type and interface type belong to which one of the above types?

A4. A class is a reference type, a structure is a value type, an array type is a reference type, an enumeration is a value type, a delegate is a reference type, and an interface is a reference type.

Q5. Determine whether the following statement is right or wrong.

1. Structures are lightweight classes.

2. Reference types are saved on the heap, and value types are saved on the stack.

3. Objects are passed by reference in C # by default.

A 5. All three statements above are wrong.

If you want to use dynamic types in Q6. C # 4, what keywords do you use?

A6.dynamic, such as dynamic o = "kkk", the responsibility for this type determination is shifted to the runtime.

The above is the site to introduce the type system in C # (value type and reference type), I hope to help you, if you have any questions welcome to leave me a message, this site will reply to you in time!


Related articles: