# C1.Util.DX.DataStream.Create

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Util_DX_DataStream_Create_" data-uid="C1.Util.DX.DataStream.Create*">Create Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Util_DX_DataStream_Create_" data-uid="C1.Util.DX.DataStream.Create*"></a>
<h4 id="C1_Util_DX_DataStream_Create__1___0___System_Boolean_System_Boolean_System_Int32_System_Boolean_" data-uid="C1.Util.DX.DataStream.Create``1(``0[],System.Boolean,System.Boolean,System.Int32,System.Boolean)">Create&lt;T&gt;(T[], bool, bool, int, bool)</h4>
<div class="markdown level1 summary"><p>Initializes a new instance of the <a class="xref" href="C1.Util.DX.DataStream.html">DataStream</a> class, using a managed buffer as a backing store.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static DataStream Create&lt;T&gt;(T[] userBuffer, bool canRead, bool canWrite, int index = 0, bool pinBuffer = true) where T : struct</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function Create(Of T As Structure)(userBuffer As T(), canRead As Boolean, canWrite As Boolean, Optional index As Integer = 0, Optional pinBuffer As Boolean = True) As DataStream</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>T[]</td>
      <td><span class="parametername">userBuffer</span></td>
      <td><p>A managed array to be used as a backing store.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">canRead</span></td>
      <td><p><code>true</code> if reading from the buffer should be allowed; otherwise, <code>false</code>.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">canWrite</span></td>
      <td><p><code>true</code> if writing to the buffer should be allowed; otherwise, <code>false</code>.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">index</span></td>
      <td><p>Index inside the buffer in terms of element count (not size in bytes).</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">pinBuffer</span></td>
      <td><p>True to keep the managed buffer and pin it, false will allocate unmanaged memory and make a copy of it. Default is true.</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.Util.DX.DataStream.html">DataStream</a></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></td>
    </tr>
  </tbody>
</table>
</div>
