Boxing and UnBoxing of C#.Net Interview Questions(5)
1.Define Boxing?
A)It is a process of
converting value type to reference type is known as boxing.
For E.G:
int a=100;
object
o=(object)a;//Boxing
2.Define UnBoxing?
A) It is a process of
converting reference type to value type is known as unboxing.
For E.G:
object o=100;
int i=(int)o;//Unboxing
object
o=(object)a;//Boxing
3.How boxing process can
be takenplace?
A)Boxing can be
takenplace implicitly in the
program.
4. How unboxing process
can be takenplace?
A)UnBoxing can be takenplace
explicitly in the program.
5.What is the process of
boxing?
A)Boxing is used to
store value types in the garbage-collected heap. Boxing is an implicit
conversion of a value type to the type object or to any interface type
implemented by this value type. Boxing a value type allocates an object
instance on the heap and copies the value into the new object. Due to this
boxing and unboxing can have performance impact.
0 comments:
Post a Comment