Performance ". NET Framework Program design" in a few lines of code, I have to rearrange, written as a function, so the following decompile code looks more convenient:
public void Boxing ()
{
Int32 v = 5;
Console.WriteLine ("{0},{1},{2}", v,v,v);
}
public void Boxing1 ()
{
Int32 v = 5;
Object o = V;
Console.WriteLine ("{0},{1},{2}", O,o,o);
The output of two functions is the same, but which function is better?
The first one is obviously simpler, but the second best in performance is to look at the decompile code:
Boxing function:
. method public Hidebysig instance void Boxing () cil managed
{
Code size:31 Byte (s)
. maxstack 4
. Locals (
Int32 v_0)
l_0000:ldc.i4.5
l_0001:stloc.0
L_0002:ldstr "{0},{1},{2}"
l_0007:ldloc.0
L_0008:box int32
l_000d:ldloc.0
L_000e:box int32
l_0013:ldloc.0
L_0014:box int32
L_0019:call void [Mscorlib]system.console::writeline (String, Object, object, object)
L_001e:ret
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service