ReportDocument report=new ReportDocument();
ExportOptions exportOpts = new ExportOptions();
exportOpts=report.ExportOptions;
請問這些代碼與下面代碼在性能上有差別嗎?
ReportDocument report=new ReportDocument();
ExportOptions exportOpts = report.ExportOptions;
ExportOptions exportOpts = new ExportOptions();
exportOpts=report.ExportOptions;
請問這些代碼與下面代碼在性能上有差別嗎?
ReportDocument report=new ReportDocument();
ExportOptions exportOpts = report.ExportOptions;
如果ExportOptions的构造函数要等待把一个火箭送上天才返回的话,那第一种方法会多浪费一架火箭.
说的对,ExportOptions exportOpts = new ExportOptions();是运行了ExportOptions的构造函数
Exception e0 = new Exception("aa");
一:
Exception e1 = new Exception();
e1 = e0;
二:
Exception e2 = e0;IL如下:
一:
L_000b: newobj instance void [mscorlib]System.Exception::.ctor(string)
L_0010: stloc.0
L_0011: newobj instance void [mscorlib]System.Exception::.ctor()
L_0016: stloc.1
L_0017: ldloc.0
L_0018: stloc.1 二:
L_000b: newobj instance void [mscorlib]System.Exception::.ctor(string)
L_0010: stloc.0
L_0011: ldloc.0
L_0012: stloc.1 一要比二多执行了一次构造。但微软推荐的写法是第一种,而且在.Net 2.0种有所改进。