title: How to convert null to default(float) or 0
body: <p>I am trying to get float values as input and if a value is skipped to just set it to 0 but since the skip sets it to null I get an exception. So, I tried using the "??" operator like this :</p>
  
  <pre><code>float speed = Convert.ToSingle(Console.ReadLine()) ?? default(float);
  </code></pre>
  
  <p>or</p>
  
  <pre><code>float speed = Convert.ToSingle(Console.ReadLine()) ?? 0;
  </code></pre>
  
  <p>But I get an error :</p>
  
  <blockquote>
    <p>error CS0019: Operator '??' cannot be applied to operands of type
    'float' and 'int'</p>
  </blockquote>
  
  <p>How would I write the equivalent of this : <code>float y = x ?? 0;</code></p>
  
  <pre><code>public static void CalculateDistanceTimeSpeed()
  {
      Console.WriteLine("Find distance/speed/time based on any of the two.");
      Console.WriteLine("Enter two of the three requirements");
      Console.WriteLine();
  
      Console.WriteLine("Enter speed in km/h (Enter 0 if unkown)");
      float speed = Convert.ToSingle(Console.ReadLine());
  
      Console.WriteLine("Enter distance in km (Enter 0 if unkown)");
      float distance = Convert.ToSingle(Console.ReadLine());
  
      Console.WriteLine("Enter time in hour/s (Enter 0 if unkown)");
      float time = Convert.ToSingle(Console.ReadLine());
  
      Console.WriteLine(distance, speed, time);
  
      if (speed == 0)
      {
          speed = distance / time;
          speed.ToString("0.##");
  
          Console.WriteLine("Determined Average speed : {1}km/h, based on distance: {0}km and time: {2}hrs.", distance, speed, time);
      }
  
      else if (distance == 0)
      {
          distance = time / speed;
          distance.ToString("0.##");
  
          Console.WriteLine("Determined distance traveled : {0}km, based on speed: {1}km/h and time: {2}hrs.", distance, speed, time);
  
      }
  
      else
      {
          time = distance / speed;
          time.ToString("0.##");
  
          Console.WriteLine("Determined time traveled: {2}hrs, based on speed: {1}km/h for distance: {0}km.", distance, speed, time);
      } 
  </code></pre>