From a technical point of view, this depends on what MyObject does in the Dispose method of the implemented IDisposable interface.
In theory, this can be perfectly normal, as you simply wrap things in an unnecessary try / catch / finally block.
public void DoStuff() { MyObject myObject = GetMyObject(); Console.WriteLine("Name: " + myObject.Name); } private MyObject GetMyObject() { using (MyObject obj = new MyObject()) { obj.Name = "Aaron"; return obj; } } public class MyObject : IDisposable { public String Name { get; set; } #region IDisposable Members public void Dispose() { //depends what you do in here... } #endregion }
Name: Aaron
source share