title: C# If Else Statement to choose the appropriate Xpath expression
body: <p>I'm writing an automation test using C#, Ranorex dll library and Xpath expressions as my locators. That's all fine but in some scenarios I want to use If Else statement to choose the appropriate Xpath from a possible 2 xpaths:</p>
  
  <pre><code>Public class Locators
  {
      public const string Xpathone = "//form[@controlname='x1']";
      public const string Xpathtwo = "//form[@controlname='x2']";
  }
  
  
  Step Definition
  [Binding]
  public class HomePageSteps
  {
      public void SelectAppropriateXpath()
      {
          Validate.Exists(HomePage.Header, Config.ExistsTimeOut);
          if (Validate.Exists(HomePage.Xpathone))==true
          {
              mouse.click(HomePage.Xpathone);
          }
          else
          {
              mouse.click(HomePage.Xpathtwo);
          }
      }
  </code></pre>
  
  <p>But I continue to get an error: </p>
  
  <blockquote>
    <p>Cannot implicitly convert type 'void' to 'bool'</p>
  </blockquote>
  
  <p>Even when I change the type to bool: </p>
  
  <blockquote>
    <p>public bool SelectAppropriateXpath()</p>
  </blockquote>
  
  <p>The error still remains and this is baffling me. And when I do use 'public bool' I also get:</p>
  
  <blockquote>
    <p>Error - not all code paths return a value</p>
  </blockquote>
  
  <p>Any thoughts would be greatly appreciated?</p>