In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article is about several representations of value type objects in programming development. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
There are two representations of value type objects: unboxed and boxed, whereas reference types are always in boxed form
2, the value type is derived from System.ValueType. This type provides the same method as System.Object. But System.ValueType overrides the Equals method to return true if the field values of the two objects match exactly. In addition, System.ValueType overrides the GetHashCode method. When generating a hash code, the algorithm used by this rewriting method takes into account the value in the instance field of the object. Because of performance problems with this default implementation, you should override the Equals and GetHashCode methods when defining your own value types and provide their display implementation
3. Since a value type cannot be used as a base type to define a new value type or a new reference type, no new virtual methods should be introduced into the value type, all methods cannot be abstract, and all methods are implicitly sealed (not rewritable).
4, the variable of the reference type contains the address of the object in the heap. Variables of reference types are initialized to null when they are created, and the table name does not currently point to valid objects. The view uses a null reference type variable to throw a NUllReferenceException exception. In contrast, variables of the value type always contain values of the underlying type, and all members of the value type are initialized to 0. 0. The value type variable is not a pointer, and it is impossible to throw a NullReferenceExcption exception to access the value type.
5. Assigning a value type variable to another value type variable performs field-by-field assignment. Assigning a variable of a reference type to a variable of another reference type only copies the memory address
6, two or more references can refer to the same object in the heap, so an operation on one variable may affect another referenced object. On the contrary, the value type variable is self-contained, and the operation on the value type variable cannot affect another value type variable.
7, because unboxed value types are not allocated on the heap, once a method that defines an example of that type is not active, the storage allocated to them is released instead of waiting for garbage collection
Thank you for reading! This is the end of this article on "there are several representations of value type objects in programming development". I hope the above content can be of some help to you, so that you can learn more knowledge. If you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.