First let me start with an example,
Public Class EmpDemo
Public Function getEmpData() as DataSet
End Function
End Class
Case 1:
Dim ds as New DataSet 'A DataSet instance gets created here
ds = EmpDemo.getEmpData() 'Another DataSet instance gets created here
Case 2:
Dim ds as DataSet
ds = EmpDemo.getEmpData() 'A single instance gets created here
Question:
How it will effect page performance if I choose Case 1 ? How I prove Case 2 is best choice?
The performance difference will be negligible, but Case 2 is obviously the better choice. Adding code that does nothing useful, in this case creating an object instance that you never use, just pollutes your code base.