A brief introduction to type systems (value types and reference types) in C #

Source: Internet
Author: User
This article mainly introduces the analysis of the type system in C # (value types and reference types), the need for friends can refer to the following

Today is to write the things are some of the concept of the book, as a copy of notes, to ask questions and dialogue in the way to write it, maybe after the interview can be a bit of conversation ~ ~ ~

  Q1. What three-point features are included in the c#1 system type?

A1. The c#1 type system is static, explicit, and secure.

  Q2. Why is it called a static type?

A2. Static types are used to describe the type of an expression at compile time, and when declaring a variable of one type, you cannot point a variable to another type of object.

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

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

Q4. Value types and reference types, respectively, what type of class, struct, array type, enumeration, delegate type, and interface type belong to the above?

A4. Class is a reference type, a struct 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. Judge the right and wrong in the following statement.

1. The structure is a lightweight class.

2. The reference type is saved on the heap, and the value type is stored on the stack.

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

A5. The above three statements are all wrong.

  Q6. What keywords are used in c#4 if you want to use a dynamic type?

A6.dynamic, such as dynamic o = "KKK", the responsibility for this type of judgment is pushed to the runtime.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.