Explain with example.Why do we need boxing and unboxing in C#?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gosai jahnvi
    New Member
    • Apr 2019
    • 22

    Explain with example.Why do we need boxing and unboxing in C#?

    Why do we need boxing and unboxing in C#?explain with example?

    I know what is boxing and unboxing , but I can't understend the real use of it. Why and where should I use it?

    Code:
    int n = 24;
    object ob = n;//boxing
    
    int m = (int) ob;//unboxing
    Last edited by gits; Apr 18 '19, 09:03 AM. Reason: added code tags
Working...