# GrapeCity.Documents.Common.ReadOnlyStructList-1.BinarySearch

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="GrapeCity_Documents_Common_ReadOnlyStructList_1_BinarySearch_" data-uid="GrapeCity.Documents.Common.ReadOnlyStructList`1.BinarySearch*">BinarySearch Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="GrapeCity_Documents_Common_ReadOnlyStructList_1_BinarySearch_" data-uid="GrapeCity.Documents.Common.ReadOnlyStructList`1.BinarySearch*"></a>
<h4 id="GrapeCity_Documents_Common_ReadOnlyStructList_1_BinarySearch_System_Int32_System_Int32__0__GrapeCity_Documents_Common_StructComparison__0__" data-uid="GrapeCity.Documents.Common.ReadOnlyStructList`1.BinarySearch(System.Int32,System.Int32,`0@,GrapeCity.Documents.Common.StructComparison{`0})">BinarySearch(int, int, in T, StructComparison&lt;T&gt;)</h4>
<div class="markdown level1 summary"><p>Searches a range of elements in the sorted <a class="xref" href="GrapeCity.Documents.Common.ReadOnlyStructList-1.html">ReadOnlyStructList&lt;T&gt;</a> for an element using the specified <a class="xref" href="GrapeCity.Documents.Common.StructComparison-1.html">StructComparison&lt;T&gt;</a> and returns the zero-based index of the element.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public int BinarySearch(int index, int count, in T item, StructComparison&lt;T&gt; comparison)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function BinarySearch(index As Integer, count As Integer, ByRef item As T, comparison As StructComparison(Of T)) As Integer</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.int32">int</a></td>
      <td><span class="parametername">index</span></td>
      <td><p>The zero-based starting index of the range to search.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">count</span></td>
      <td><p>The length of the range to search.</p>
</td>
    </tr>
    <tr>
      <td><span class="xref">T</span></td>
      <td><span class="parametername">item</span></td>
      <td><p>The object to locate.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="GrapeCity.Documents.Common.StructComparison-1.html">StructComparison</a>&lt;T&gt;</td>
      <td><span class="parametername">comparison</span></td>
      <td><p>The <a class="xref" href="GrapeCity.Documents.Common.StructComparison-1.html">StructComparison&lt;T&gt;</a> to use when comparing elements.</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="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><p>The zero-based index of <code class="paramref">item</code> in the sorted <a class="xref" href="GrapeCity.Documents.Common.ReadOnlyStructList-1.html">ReadOnlyStructList&lt;T&gt;</a>, if <code class="paramref">item</code> is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than <code class="paramref">item</code> or, if there is no larger element, the bitwise complement of <a class="xref" href="GrapeCity.Documents.Common.ReadOnlyStructList-1.Count.html#GrapeCity_Documents_Common_ReadOnlyStructList_1_Count">Count</a>.</p>
</td>
    </tr>
  </tbody>
</table>


<a id="GrapeCity_Documents_Common_ReadOnlyStructList_1_BinarySearch_" data-uid="GrapeCity.Documents.Common.ReadOnlyStructList`1.BinarySearch*"></a>
<h4 id="GrapeCity_Documents_Common_ReadOnlyStructList_1_BinarySearch_System_Int32_System_Int32__0__GrapeCity_Documents_Common_IStructComparer__0__" data-uid="GrapeCity.Documents.Common.ReadOnlyStructList`1.BinarySearch(System.Int32,System.Int32,`0@,GrapeCity.Documents.Common.IStructComparer{`0})">BinarySearch(int, int, in T, IStructComparer&lt;T&gt;)</h4>
<div class="markdown level1 summary"><p>Searches a range of elements in the sorted <a class="xref" href="GrapeCity.Documents.Common.ReadOnlyStructList-1.html">ReadOnlyStructList&lt;T&gt;</a> for an element using the specified comparer and returns the zero-based index of the element.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public int BinarySearch(int index, int count, in T item, IStructComparer&lt;T&gt; comparer)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function BinarySearch(index As Integer, count As Integer, ByRef item As T, comparer As IStructComparer(Of T)) As Integer</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.int32">int</a></td>
      <td><span class="parametername">index</span></td>
      <td><p>The zero-based starting index of the range to search.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">count</span></td>
      <td><p>The length of the range to search.</p>
</td>
    </tr>
    <tr>
      <td><span class="xref">T</span></td>
      <td><span class="parametername">item</span></td>
      <td><p>The object to locate.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="GrapeCity.Documents.Common.IStructComparer-1.html">IStructComparer</a>&lt;T&gt;</td>
      <td><span class="parametername">comparer</span></td>
      <td><p>The <a class="xref" href="GrapeCity.Documents.Common.IStructComparer-1.html">IStructComparer&lt;T&gt;</a> implementation to use when comparing elements.</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="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><p>The zero-based index of <code class="paramref">item</code> in the sorted <a class="xref" href="GrapeCity.Documents.Common.ReadOnlyStructList-1.html">ReadOnlyStructList&lt;T&gt;</a>, if <code class="paramref">item</code> is found; otherwise, a negative number that is the bitwise complement of the index of the next element that is larger than <code class="paramref">item</code> or, if there is no larger element, the bitwise complement of <a class="xref" href="GrapeCity.Documents.Common.ReadOnlyStructList-1.Count.html#GrapeCity_Documents_Common_ReadOnlyStructList_1_Count">Count</a>.</p>
</td>
    </tr>
  </tbody>
</table>
</div>
