How in increase the performance while creating an object of a class in c# -
i know silly question ask, want know difference in below given statements:
abc object= new abc(); object.age=obj1.age; object.place=obj1.place; object.street=obj1.street; object.number=obj1.number; object.pobox=obj1.pobox;
and
abc object= new abc() { age=obj1.age, place=obj1.place, street=obj1.street, number=obj1.number, pobox=obj1.pobox };
will above written code in increasing performance? want know if there way can increase performance while creating object of class , assigning values class object?
no. these statements compiled same il there no performance improvement.
the first one:
il_0031: newobj instance void testapplication.abc::.ctor() il_0036: stloc.1 il_0037: ldloc.1 il_0038: ldc.i4.1 il_0039: callvirt instance void testapplication.abc::set_age(int32) il_003e: nop il_003f: ldloc.1 il_0040: ldc.i4.1 il_0041: callvirt instance void testapplication.abc::set_place(int32) il_0046: nop il_0047: ldloc.1 il_0048: ldc.i4.1 il_0049: callvirt instance void testapplication.abc::set_street(int32) il_004e: nop il_004f: ldloc.1 il_0050: ldc.i4.1 il_0051: callvirt instance void testapplication.abc::set_number(int32) il_0056: nop il_0057: ldloc.1 il_0058: ldc.i4.1 il_0059: callvirt instance void testapplication.abc::set_pobox(int32)
and second one:
il_0001: newobj instance void testapplication.abc::.ctor() il_0006: stloc.2 il_0007: ldloc.2 il_0008: ldc.i4.1 il_0009: callvirt instance void testapplication.abc::set_age(int32) il_000e: nop il_000f: ldloc.2 il_0010: ldc.i4.1 il_0011: callvirt instance void testapplication.abc::set_place(int32) il_0016: nop il_0017: ldloc.2 il_0018: ldc.i4.1 il_0019: callvirt instance void testapplication.abc::set_street(int32) il_001e: nop il_001f: ldloc.2 il_0020: ldc.i4.1 il_0021: callvirt instance void testapplication.abc::set_number(int32) il_0026: nop il_0027: ldloc.2 il_0028: ldc.i4.1 il_0029: callvirt instance void testapplication.abc::set_pobox(int32)
Comments
Post a Comment