The type and access modifier in. net

Source: Internet
Author: User
Document directory
  • About types
  • Access Modifier
About types

For. Net types, we can see the value type and reference type in many places on the Internet. I think so too. It seems that there is no error in this regard. However, from an academic point of view, this article tells you where you want to think about it. You just need to have a chat with other colleagues after a meal and just listen to it.

There are two types:

To put it simply:

Value types: The type inherited from system. valuetype.

Generic Type parameters: type with generic parameters, that is, the so-called "Open Type" mentioned by debuglzq in generics. It features that it cannot be instantiated before t is specified. For details, refer to the post above debuglzq: introduction to the basic principles of generic in. net.

Pointer types: pointer type, an unsafe unmanaged type.

Reference types: Other types other than the preceding three types. Note that system. valuetype and all reference types are inherited from the system. Object base class.

We usually talk about. net System. object is a base class of all types. In fact, we can define a class by ourselves and do not inherit from the system. object,. net strongly does not recommend us to do this. If you are interested, you can check the CLR to see the specific implementation. Actually. all existing interfaces, such as ilist, iemumerable, and icollection, are not inherited from system. object, because when you open its Il, you cannot find the extends system. objects are not inherited from any class. Refer to Wang Tao's blog post: [. Net you must know] 27th: Does interface inherit from objects?

Access Modifier

I didn't plan to write this item. Since we have all said the type, I will take the access modifier and write it in a word --!.

 

Make a table to explain:

C # terminology

CLR terminology

Private

Private

Protected

Family

Not Supported

Family and assembly

Internal

Assembly

Protected internal

Family or assembly

Public

Public

 

 

 

 

 

 

 

 

 

 

 

I still remember when I interviewed the company, the first question that the vice president of technology talked about was the. NET type and access modifier. At that time, I answered the latter and chatted happily.

Remember to mention that C #5.0 in a nutshell is used to increase the attention of this article. (Without a license, whoever is idle will hurt you ,--!)

There is no high-end technology, so you can bypass and pat your shots...

 

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.