title: Cannot implicitly convert type 'System.DateTime?' to 'System.DateTime'. An explicit conversion exists
body: <p>I am trying to convert <code>DateTime?</code> to <code>DateTime</code> but I get this Error:</p>
  <blockquote>
  <p>Error 7   Cannot implicitly convert type 'System.DateTime?' to
  'System.DateTime'. An explicit conversion exists</p>
  </blockquote>
  <p>Here is my code:</p>
  <pre><code>public string ConvertToPersianToShow(DateTime?  datetime)
  {
    DateTime dt;
    string date;
    dt = datetime;
      
    string year = Convert.ToString(persian_date.GetYear(dt));
    string month = Convert.ToString(persian_date.GetMonth(dt));
    string day = Convert.ToString(persian_date.GetDayOfMonth(dt));
      
    if (month.Length == 1)
    {
       month = &quot;0&quot; + Convert.ToString(persian_date.GetMonth(dt));
    }
    if (day.Length == 1)
    {
       day = &quot;0&quot; + Convert.ToString(persian_date.GetDayOfMonth(dt));
    }
  
    //date = Convert.ToString(persian_date.GetYear(dt)) + &quot;/&quot; + 
    Convert.ToString(persian_date.GetMonth(dt)) + &quot;/&quot; +
    //Convert.ToString(persian_date.GetDayOfMonth(dt));
    date = year + &quot;/&quot; + month + &quot;/&quot; + day+&quot;(&quot;+dt.Hour+&quot;:&quot;+dt.Minute+&quot;)&quot;;
  
    return date;
  }
  </code></pre>