I've been given some code to maintain has this structure throughout:
Code:
public DataSet GetData()
{
using(DataSet myData =
// local method that hits a database
RunProcedure(
"fetch_data",
new IDataParameter[]{},
"dataType"))
{
return myData;
}
}
I'm relatively new to dotNet so I'm unsure, but I'm thinking that the using block is completely useless here. If the object were actually getting disposed, the method would not be useful. I'm betting that the object is not disposed, the local reference goes out of scope, and the returned object should then be disposed when appropriate.
Hopefully someone here can verify or refute my theory.
-Andy