incase if you dont want to use the object created by the below statement in the subsequent statments then you can do like below else you can follow the above one.
DataTable dt = new DataAccess().GetDataTable(ConnString, CommandType.Text);
Thanks,
Karthick S
Marked as answer by dundealing on Oct 08, 2010 02:54 PM
dundealing
Member
15 Points
53 Posts
What's the difference?
Oct 08, 2010 11:09 AM|LINK
Hi,
can anyone tell me if there is a performance diference between these two ways of calling an instance method?
DataAccess da = new DataAccess();
DataTable dt = da.GetDataTable(ConnString, CommandType.Text);
and:
DataTable dt = new DataAccess().GetDataTable(ConnString, CommandType.Text);
Is one preferable over the other?
Thanks in advance.
karthicks
All-Star
31382 Points
5424 Posts
Re: What's the difference?
Oct 08, 2010 11:30 AM|LINK
hi,
it's just a shortcut to
DataAccess da = new DataAccess();
incase if you dont want to use the object created by the below statement in the subsequent statments then you can do like below else you can follow the above one.
DataTable dt = new DataAccess().GetDataTable(ConnString, CommandType.Text);
Karthick S
parthasbhadr...
Participant
754 Points
151 Posts
Re: What's the difference?
Oct 08, 2010 11:37 AM|LINK
It only reduces LOC
if you dont want to use the object more than one within a scope then you can use
DataTable dt = new DataAccess().GetDataTable(ConnString, CommandType.Text);
Thanks
Partha