'get dropdown item count using selenium c#

IWebElement from = m_driver.FindElement(By.XPath("mydropdownxpath"));
from.Click(); // to open dropdown

My dropdown type is input dropdown and I haven't used SelectElement or IList in my code. How can i get dropdown item count with below as my source code?

<select class="classname" name="ddldropdown" required>

<option data-fas="themered" value="" disabled selected>state</option>

<optgroup label="area">
   <option data-fas="maptheme" value="state1"> state 1 </option>
   <option data-fas="maptheme" value="state2"> state 2 </option>
</optgroup>

<optgroup label="Airport">
   <option data-fas="maptheme" value="ABC"> ABC </option>
   <option data-fas="maptheme" value="XYZ"> XYZ </option>
</optgroup>                       

</select>   


Solution 1:[1]

Your dropdown is <select>, not <input>. SelectElement is the correct way to handle it

IWebElement from = m_driver.FindElement(By.XPath("mydropdownxpath"));
SelectElement select = SelectElement(form);
int count = select.Options.Count; // 5

Solution 2:[2]

To make this work, I had to change the second line to

SelectElement select = new SelectElement(form);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Guy
Solution 2 Peter Csala