Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

291
Views
Ventana inmediata: ¿transmitir como fecha y hora? lanza una excepción pero (datetime) no

Tomado directamente de la ventana inmediata:

reader["DateDue"] as DateTime? rendimientos:

 'reader["DateDue"] as DateTime?' threw an exception of type 'System.NullReferenceException' Data: {System.Collections.ListDictionaryInternal} HResult: -2147467261 HelpLink: null InnerException: null Message: "Object reference not set to an instance of an object." Source: null StackTrace: null TargetSite: null

(DateTime?)reader["DateDue"] produce:

 {1/26/2015 12:00:00 AM} Date: {1/26/2015 12:00:00 AM} Day: 26 DayOfWeek: Monday DayOfYear: 26 Hour: 0 Kind: Unspecified Millisecond: 0 Minute: 0 Month: 1 Second: 0 Ticks: 635578272000000000 TimeOfDay: {System.TimeSpan} Year: 2015

y como referencia, reader["DateDue"] produce:

 {1/26/2015 12:00:00 AM} Date: {1/26/2015 12:00:00 AM} Day: 26 DayOfWeek: Monday DayOfYear: 26 Hour: 0 Kind: Unspecified Millisecond: 0 Minute: 0 Month: 1 Second: 0 Ticks: 635578272000000000 TimeOfDay: {00:00:00} Year: 2015

¿Es esto un error? Si se envía directamente a DateTime? ¿Funciona luego con casting as DateTime? debería funcionar también.

Encontré una solución para esto usando reader.GetDateTime(reader.GetOrdinal("DateDue")) as DateTime? . No importa, eso no maneja bien los valores nulos. De todos modos, hay una miríada de maneras de papel en torno a esta rareza.

El repositorio que demuestra el problema se puede encontrar aquí: https://github.com/jjoedouglas/exceptionAsDatetime

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Esto parece ser un error en la ventana inmediata de VS2015.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!