What exactly happens when I cast by reference types and value types and vice versa (boxing and un boxing) at the compiler or run level? Can any body explain the following four conditions? Please feel free to add terms if I skip any.
1. Stream stream = new MemoryStream(); MemoryStream memoryStream = (MemoryStream) stream; 2. double k=10.0; int l = (int)k; 3. object k =20; int l = (int)k; 4. int k =23; double m = k;
Three types of conversions take place here:
1 . CLR , stream MemoryStream ( ), MemoryStream. - . stream MemoryStream . .
stream
MemoryStream
2 4 - . FPU. 2 ( ), 4 , , .
3 unboxing: CLR , k int ( , int), l.
k
int
l
IL, , , , , , ildasm Reflector.
, .
Source: https://habr.com/ru/post/1744289/More articles:Passing an Ajax variable to Codeigniter - jquerypolymorphism in java - javaHow can I name the IP address? - tomcat6How to synchronize two folders in PHP? - synchronizationComponent for cube processing - c #NHibernate LINQ query raises "Failed to resolve property" error - linqrc android disabled - androidCreating SHP from SQL - postgisGetting the most recent record for each group in a select statement - sqlwebsockets protocols? - html5All Articles