Boxing and Unboxing in .NET
Wednesday, 3 May 2017
.NET
BOXING AND UNBOXING -
Boxing -
Boxing เคตเคน process เคนोเคคी เคนै เคिเคธเคฎें value type เคो object type เคฏा reference type เคฎें convert เคिเคฏा เคाเคคा เคนै।
เคเคธ process เคो implicit process เคญी เคเคนเคคे เคนैं।
Example - int i=123;
Object(O)=i;
เคเคธเคฎें O, i เคा เคฐेเคซเคฐेंเคธ เคฆे เคฐเคนा เคนै।
เคเคธ process เคो implicit process เคญी เคเคนเคคे เคนैं।
Example - int i=123;
Object(O)=i;
เคเคธเคฎें O, i เคा เคฐेเคซเคฐेंเคธ เคฆे เคฐเคนा เคนै।
Unboxing -
Unboxing เคตเคน process เคนै เคो object เคฏा reference type เคธे value เคो value type เคฎें convert เคเคฐ เคฆेเคคी เคนै।
เคเคธ process เคो explicit process เคญी เคเคนเคคे เคนैं।
เคเคธ process เคो explicit process เคญी เคเคนเคคे เคนैं।
Example- O=123;
i=(int)O;
เคเคธ example เคธे object 'O' unbox เคนो เคाเคฏेเคा เคเคฐ เคเคธเคी value integer 'i' เคฎें เคเคฒी เคाเคฏेเคी เคฏा convert เคนो เคाเคฏेเคी।
Example-
class test Boxing
{
Public static void main(string()args)
{
int i=123;
object O=i;
i=456;
system.console.write("the value type value is={0}"i);
system.console.write("the object type value is={0}"O);
console.Readline();
}
}
Output-
the value type value is = 456
the object type value is = 123
Very nice explanation. Thanks
ReplyDelete