Boxing and Unboxing in .NET
Am looking for the exact answer to find out in what way that boxing and unBoxing are used in .NET
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Tapan PatelPosted Sep 1, 2016, 10:14 AM
If you know the difference between stack and heap à any variable (of primitive data types like int , bool, double and so on ) gets stored on the stack where as any object is stored on the different data structure of the memory called heap.
Consider below example.
If you look at statement for int and bool, CLR allocates memory on the stack.
So if you do something (a standard example) like this:
That is why it is advisable not to use Int or Boolean , instead use int, bool so that you will save some time that makes CLR to move code from stack to Heap. So bottom line is , if you don't need it, don't use it as it causes performance hits.
Please mark it as an answer if addresses the issue.
Menaka Priyadharshini BPosted Sep 1, 2016, 10:17 AM
Krishna Rajput SinghPosted Sep 1, 2016, 9:38 AM
Midhun TpPosted Sep 1, 2016, 9:21 AM