# C1.DataCollection.IDataCollectionEx.ToDataCollection

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_DataCollection_IDataCollectionEx_ToDataCollection_" data-uid="C1.DataCollection.IDataCollectionEx.ToDataCollection*">ToDataCollection Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_DataCollection_IDataCollectionEx_ToDataCollection_" data-uid="C1.DataCollection.IDataCollectionEx.ToDataCollection*"></a>
<h4 id="C1_DataCollection_IDataCollectionEx_ToDataCollection__1_System_Collections_IEnumerable_" data-uid="C1.DataCollection.IDataCollectionEx.ToDataCollection``1(System.Collections.IEnumerable)">ToDataCollection&lt;T&gt;(IEnumerable)</h4>
<div class="markdown level1 summary"><p>Wraps an <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.ienumerable">IEnumerable</a> into a data collection.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">[Obsolete(&quot;Use AsDataCollection instead&quot;, true)]
public static IDataCollection&lt;T&gt; ToDataCollection&lt;T&gt;(this IEnumerable source) where T : class?</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">&lt;Obsolete(&quot;Use AsDataCollection instead&quot;, True)&gt;
Public Shared Function ToDataCollection(Of T As Class)(source As IEnumerable) As IDataCollection(Of 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><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.ienumerable">IEnumerable</a></td>
      <td><span class="parametername">source</span></td>
      <td><p>The source of the data collection.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.DataCollection.IDataCollection-1.html">IDataCollection</a>&lt;T&gt;</td>
      <td></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 the data collection.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="C1_DataCollection_IDataCollectionEx_ToDataCollection_" data-uid="C1.DataCollection.IDataCollectionEx.ToDataCollection*"></a>
<h4 id="C1_DataCollection_IDataCollectionEx_ToDataCollection__1_System_Collections_Generic_IEnumerable___0__" data-uid="C1.DataCollection.IDataCollectionEx.ToDataCollection``1(System.Collections.Generic.IEnumerable{``0})">ToDataCollection&lt;T&gt;(IEnumerable&lt;T&gt;)</h4>
<div class="markdown level1 summary"><p>Wraps an <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.ienumerable">IEnumerable</a> into a data collection.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">[Obsolete(&quot;Use AsDataCollection instead&quot;, true)]
public static IDataCollection&lt;T&gt; ToDataCollection&lt;T&gt;(this IEnumerable&lt;T&gt; source) where T : class?</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">&lt;Obsolete(&quot;Use AsDataCollection instead&quot;, True)&gt;
Public Shared Function ToDataCollection(Of T As Class)(source As IEnumerable(Of T)) As IDataCollection(Of 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><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1">IEnumerable</a>&lt;T&gt;</td>
      <td><span class="parametername">source</span></td>
      <td><p>The source of the data collection.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="C1.DataCollection.IDataCollection-1.html">IDataCollection</a>&lt;T&gt;</td>
      <td></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 the data collection.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
