Tech Off Post

Single Post Permalink

View Thread: C# Sting converstion
  • User profile image

    W3bbo said:

    An "int" date?


    If you've got a DateTime instance, just call myDate.ToString(); you can optionally specify a format-string or predefined culture settings to get the right format (e.g. myDate.ToString("yyyy-MM-dd"); or myDate.ToString(CultureInfo.CurrentCulture); )


    In .NET, every class inherits Object's .ToString() method, by default this method simply returns some basic information gained from Reflection, but some types (such as DateTime) override the behaviour. There is also the System.Convert class, but I find myself rarely using it (since it's nothing you can't do with the existing .TryParse / .Parse / .ToString methods.

    I'm no good at this, this is my code.

    there is an error on the line, [string mydate..... ]and the next one ????????


    int thedate = this.dateTimePicker1.Value.Day & this.dateTimePicker1.Value.Month & this.dateTimePicker1.Value.Year;

    string mydate = thedate.ToString;