# C1.Util.DX.DXUtil.Dispose

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Util_DX_DXUtil_Dispose_" data-uid="C1.Util.DX.DXUtil.Dispose*">Dispose Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Util_DX_DXUtil_Dispose_" data-uid="C1.Util.DX.DXUtil.Dispose*"></a>
<h4 id="C1_Util_DX_DXUtil_Dispose__1___0__" data-uid="C1.Util.DX.DXUtil.Dispose``1(``0@)">Dispose&lt;T&gt;(ref T)</h4>
<div class="markdown level1 summary"><p>Safely dispose a referencem if not null, and set it to null after dispose.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static void Dispose&lt;T&gt;(ref T comObject) where T : class, IDisposable</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Sub Dispose(Of T As {Class, IDisposable})(ByRef comObject As T)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="xref">T</span></td>
      <td><span class="parametername">comObject</span></td>
      <td><p>Object to dispose.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="typeParameters">Type Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><span class="parametername">T</span></td>
      <td><p>The type of COM interface to dispose.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Util_DX_DXUtil_Dispose__1___0___remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>The reference will be set to null after dispose.</p>
</div>
</div>
