title: c#: How to parse & validate datetime string that has auto-generated format
body: <p>I am generating a string datetime value using:</p>
  <pre><code>string str = DataTime.Now.ToString(CultureInfo.CurrentCulture)
  </code></pre>
  <p>this gives out &quot;09/22/2020 5:30:01 PM&quot; as per my existing local machine settings.</p>
  <p>In my ui I edit it to :
  string bad_year = &quot;09/22/202 5:30:01 PM&quot;;</p>
  <p>Now, when i am trying to parse/validate it using:</p>
  <pre><code>var style = System.Globalization.DateTimeStyles.AllowWhiteSpaces;
  var cul = System.Globalization.CultureInfo.CurrentCulture;
  DateTime.TryParse(bad_year, cul, style, out dt_out); 
  </code></pre>
  <p>dt_out gives: 09/22/0202 5:30:01 PM</p>
  <p>I <em>expect</em> the dt_out to be null as it has wrong year in it.  Any idea?  Thanks a lot.</p>
  <p>(Here, if we chose to use DateTime.TryParseExact(..) then we have to supply the format which i don't want to do explicitly and it should be automatically picked up from current CultureInfo) )</p>