equivalent of isdate in C#.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cmrhema
    Contributor
    • Jan 2007
    • 375

    equivalent of isdate in C#.net

    Hi, All

    We have a function called IsDate in Visual Basic that will determine if the given string is date or not.

    Do we have any such function in C#.

    Regards
    cmrhema
  • sudhaMurugesan
    New Member
    • May 2007
    • 94

    #2
    Hi,
    You can use Datetime.Trypar se method
    DateTime date1
    if (!(DateTime.Try Parse(txtDate.T ext, out date1)))
    {
    lblMessage.Text = "Enter correct date !";
    return;
    }
    else
    {
    //do the task
    }

    Comment

    • cmrhema
      Contributor
      • Jan 2007
      • 375

      #3
      Originally posted by sudhaMurugesan
      Hi,
      You can use Datetime.Trypar se method
      DateTime date1
      if (!(DateTime.Try Parse(txtDate.T ext, out date1)))
      {
      lblMessage.Text = "Enter correct date !";
      return;
      }
      else
      {
      //do the task
      }

      Thanks a million, was looking for this for quite a long time

      Comment

      • sudhaMurugesan
        New Member
        • May 2007
        • 94

        #4
        Originally posted by cmrhema
        Thanks a million, was looking for this for quite a long time
        u r welcome. I am happy that this time i can help u.

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          Originally posted by cmrhema
          Thanks a million, was looking for this for quite a long time
          Pretty much every basic type (int,float,date time) has the .Parse() function (and most have .TryParse())

          Comment

          Working...