Learned the "Boxing and Unboxing (C# Programming Guide)" article from msdn.
These lines are called boxing and unboxing.
int i = 123;
// The following line boxes i.
object o = i;
o = 456;
i = (int)o; // unboxing
My question is, is the following codes also called "unboxing"? If so, does it suffer the same performance penalty like above codes?
int i = 10;
object o = i;
if (o is int j) // unboxing?
{
System.Console.WriteLine(j);
}
if (o is 10) // one further step, unboxing?
{
System.Console.WriteLine("It`s 10! ");
}