Click here to Skip to main content
16,023,047 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
what is difference between below 2 scenarios

1)Dataset ds= new Dataset();
Dataadapter.fill(ds,"emp");

2)Dataset ds;
Dataadapter.fill(ds,"emp");

in scenario 1 created dataset object with new keyword and used that that object. In scenario 2 created dataset object with out using new keyword.

Is there any difference b/w 2 scenarios.memorywise or anything......


Thanks All.
Posted

This is a common mistake done by programmers.

In the first case firstly memory is allocated for dataset. The moment you call the fill method, dataset object is given reference to a new dataset filled with data. garbage collector clears memory allocated in first line.

In second case no such memory allocation is done so can be called as efficient code.
 
Share this answer
 
Yes, of course. In the first scenario you created a dataset which was then replaced by the dataset created by the Fill method. In the real world, it's not a big deal, but it's less efficient.
 
Share this answer
 
there is no difference other than these two
 
Share this answer
 
In the first one we r using a constructor new of dataset class in order to create a dataset but in the second on not :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900