Through the previous study, we can basically realize the conversion between the value type and the value type, the conversion between the reference type and the reference type, but how is the conversion between the value type and the reference type (
When it comes to packing and unpacking, Debuglzq believes that the Bo friends in the garden must be able to tell the way, presumably meaning that the value type and the reference type of the mutual conversion of the---value type to the reference
In order to facilitate the development of the article, first introduced the boxing (Boxing) and unpacking (unboxing) these two nouns. NET type is divided into two types, one is the value type and the other is the reference type. The essential
Visual C # Boxing and unboxing research
2004-09-15 Author: Origin: CSDN
Before we begin to discuss this issue, we may wish to ask a few questions to systematically understand the subject we are exploring today.
The viewer may have used countless
, boxing and unpacking is an abstract concept 2, boxing is theValue types are converted toobject type is converted to each other, and the value type is linked to the reference type for example: int val =, Object obj = val; Console.WriteLine ("Value
Drill down into C # memory management to analyze the difference between value types & reference types, boxing & unboxing, stacks of several concept combinations-c# beginners are often asked a few questions, value type and reference type, boxing and
1.Boxing and unpacking is an abstract concept.2.Boxing is converting a value type to a reference type; unpacking is converting a reference type to a value typeWith boxing and unboxing, you can link value types to reference types by allowing any
1, boxing and unpacking is an abstract concept
2, boxing is to convert a value type to a reference type;
Unboxing is converting a reference type to a value type
With boxing and unboxing, you can link value types to reference types by allowing any
First look at the following code:
Copy Code code as follows:
int tempi = 1;
Object o = tempi;
Double tempd = (double) o;
The compile-time can pass, but the runtime reports the following error:
System.InvalidCastException:
1.Boxing and unpacking is an abstract concept.2.Boxing is theValue types are converted toThe type of reference, unpacking is theThe reference type is converted to take advantage of the boxing and unpacking feature, which allows object type is
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.