title: How do we return the value of a variable whose value is assigned inside an IF statement?
body: <p>I have recently been making a calculator project and I have run into a small problem.</p>
  
  <pre><code>   internal static float Answer_Descision(string[] Data, float num1, float num2, string operand) 
     {
          string operand_types = ["*", "+", "/", "pwr", "-"];
          float ans;
          int Lenth_Of_Data = Data.Length;
          bool Help = Data[1] == "Help";
          if (Lenth_Of_Data == 1 &amp;&amp; Help)
          {
              Console.WriteLine("The availible operands as of version 1.2 of the calculator are:\n1. \"+\"\n2. \"-\"\n3. \"*\"\n4. \"/\"\n5. \"pwr\"\n");
          }
          else if(operand == operand_types)
          { 
              ans = Operation_Descision(num1, operand, num2);
          }
          return ans;
     }
  </code></pre>
  
  <p>I basically want to assign a value to the variable "ans" inside the if statement.</p>
  
  <p>But now when I do this it displays the following error for the return word:
   Use of unassigned variable "ans".</p>
  
  <p>I want to know, how to assign the value of ans to it inside the if statement?</p>