Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8309751
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:13:04+00:00 2026-06-08T19:13:04+00:00

I was working with some legacy code today and noticed something strange. We have

  • 0

I was working with some legacy code today and noticed something strange. We have some old ADO .NET code that’s reading some data from a database into a DataTable.

At some point in time, the following code

SubscriptionDT.Rows[0]["LastShownBenefits"].ToString().Substring(0, 10)

returned

2001-01-01

However, now it returns

1/1/2001 1

If I quickwatch SubscriptionDT.Rows[0]["LastShownBenefits"] it seems to be able to infer that the type is of System.DateTime. (This column is a DateTime in the database). However, I have a feeling that before we upgraded the project to .NET 3.5, this was probably recognized as a System.Object. Obviously, calling .ToString() returns different results between the two…

My questions are:

1) Am I right about type inference? I thought this might be the case since the var keyword was introduced in .NET 3.5.

2) Is there any documentation available for this change (or similar changes)? I’ve been searching MSDN for some time now, but haven’t been able to find anything.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T19:13:05+00:00Added an answer on June 8, 2026 at 7:13 pm

    No, you are not right. The reason is that now a different locale is being used for whatever reason.
    That’s why you should always specify the culture in a call to ToString to avoid exactly this type of problem.

    To be clear: This has absolutely nothing to do with type inference. The object was a boxed DateTime in .NET 2.0 and it still is a boxed DateTime in .NET 3.5.

    The var keyword is strictly a compile time feature. There is no difference in the resulting IL between code using the var keyword and code that explicitly specifies the type of a variable, e.g.:

    var date = DateTime.Now;
    // results in exactly the same IL code as:
    DateTime date = DateTime.Now;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on some legacy code and have come across something that I'm
I am working on some legacy code. I have the following data types: typedef
I'm working on a project that combines .NET with some legacy ASP code via
Hi I'm working on some legacy code that goes something along the lines of
I'm working on some legacy code and I ran into something that I'm not
I am working on some legacy C code and have come accross two strange
I have been working on some legacy C++ code that uses variable length structures
I'm working with some legacy code that has an import like so: #import C:\Program
I'm working updating some legacy code that does not properly handle user input. The
I am working on some legacy code, and I have the following wonderful issue.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.