title: Cleaning up resources
body: <p>Am trying to clean up resources in my C# code.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>finally
  {
  object[] myarray = new object[5] { globalRelation, asset, surfaceRelationNew, termStructureSlice,   equipRelation };
  
  CleanupResource(myarray);
  }
  
  
  private void CleanupResource(params object[] objs)
  {
            for (int count = 0; count &lt; objs.Length; count++)
                  {
                      if (objs[count] != null)
                      {
                          Marshal.ReleaseComObject(objs[count]);
                      }
  
                  }
  }
  </code></pre>
  
  <p>Is this is a good approach?
  Or shall I call CleanupResource() method for each object rather than passing an array and then looping thru it.</p>
  
  <p>Please suggest.</p>