Tech Off Post

Single Post Permalink

View Thread: C# Sting converstion
  • User profile image

    TommyCarlier said:
    W3bbo said:

    Converting to string, substringing and parsing to integers is not really nice. And the DateTime-constructor you use is used wrongly: the first argument is the year and not the day.

    Long live integer division and modulo:

    int d = 25122009;
    DateTime date =
      new DateTime(
        d / 1000000,
        (d / 10000) % 100,
        d % 10000);

    Why can the first argument not be the day ?