# C1.Framework.EnumHelper.IsValid

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Framework_EnumHelper_IsValid_" data-uid="C1.Framework.EnumHelper.IsValid*">IsValid Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Framework_EnumHelper_IsValid_" data-uid="C1.Framework.EnumHelper.IsValid*"></a>
<h4 id="C1_Framework_EnumHelper_IsValid_System_Int32_System_Int32_System_Int32_" data-uid="C1.Framework.EnumHelper.IsValid(System.Int32,System.Int32,System.Int32)">IsValid(int, int, int)</h4>
<div class="markdown level1 summary"><p>Check current value is a valid Enum type</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static bool IsValid(int enumValue, int minValueOfEnum, int maxValueOfEnum)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function IsValid(enumValue As Integer, minValueOfEnum As Integer, maxValueOfEnum As Integer) As Boolean</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">enumValue</span></td>
      <td><p>An <b>int</b> indivate the value you want to check</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">minValueOfEnum</span></td>
      <td><p>An <b>int</b> indicate the minimum value of your enum type</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">maxValueOfEnum</span></td>
      <td><p>An <b>int</b> indicate the maximum value of your enum type</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.boolean">bool</a></td>
      <td><p>A <b>bool</b> indicate the check result, if current value is a valid enum type, return <b>true</b>;
otherwise <b>false</b></p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Framework_EnumHelper_IsValid_System_Int32_System_Int32_System_Int32__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method is applicable to check a <b>Sequential</b> defined not-flag-style enum type</p>
</div>


<a id="C1_Framework_EnumHelper_IsValid_" data-uid="C1.Framework.EnumHelper.IsValid*"></a>
<h4 id="C1_Framework_EnumHelper_IsValid_System_Int32_System_Int32_System_Int32_System_Int32_" data-uid="C1.Framework.EnumHelper.IsValid(System.Int32,System.Int32,System.Int32,System.Int32)">IsValid(int, int, int, int)</h4>
<div class="markdown level1 summary"><p>Check current value is a valid Enum type</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public static bool IsValid(int enumValue, int minValueOfEnum, int maxValueOfEnum, int maxNumberOfBitsOn)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Shared Function IsValid(enumValue As Integer, minValueOfEnum As Integer, maxValueOfEnum As Integer, maxNumberOfBitsOn As Integer) As Boolean</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">enumValue</span></td>
      <td><p>An <b>int</b> indivate the value you want to check</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">minValueOfEnum</span></td>
      <td><p>An <b>int</b> indicate the minimum value of your enum type</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">maxValueOfEnum</span></td>
      <td><p>An <b>int</b> indicate the maximum value of your enum type</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">maxNumberOfBitsOn</span></td>
      <td><p>An <b>int</b> indicate the max count of bit for test enum value</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.boolean">bool</a></td>
      <td><p>A <b>bool</b> indicate the check result, if current value is a valid enum type, return <b>true</b>;
otherwise <b>false</b></p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Framework_EnumHelper_IsValid_System_Int32_System_Int32_System_Int32_System_Int32__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>This method is applicable to check a <b>Sequential</b> defined flag-style enum type
<example>
There is a enum value you want to test is <b>0x5f</b>, in this enum type, the min value is <b>0x0f</b>,
and max value is <b>0x100</b>, then this method called below can test its validation:</example></p>
<pre><code class="lang-csharp">EnumHelper.IsValid(0x5f, 0x0f, 0x100, 8);</code></pre>
<p>In this scenario, the four parameter is <b>8</b>, because the max value is <b>0x100</b>(Binary as 100000000),
the max bits on value is <b>0xff</b> (Binary as 11111111), it's the max number of bits on
</p>
</div>
</div>
