Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Boxing and Unboxing

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 169
    Comment on it

    Hi Team,

    Today i will explain Boxing and Unboxing in C#.

    C# Type system mainly divided into 3 parts:-

    1. Value Type

    2. Reference Type

    3. Pointer Type

    bool,byte,char,decimal,double,float,int,long,short are the value types

    struct ,Class and object are reference type

    Converting a value type to reference type is known as boxing and reference to value type is known as unboxing.

    I will show it with the help of example below :-

         //Boxing Example
         int x = 1;
         object obj = x;
    
         //Unboxing Example
         int y = (int)obj;

    To explore more you can take reference from here :-

    https://msdn.microsoft.com/en-us/library/ms173104.aspx

    Thanks

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: