datetime - C# Casting vs. Parse -
this may seem rudimentary some, question has been nagging @ me , write code, figured ask.
which of following better code in c# , why?
((datetime)g[0]["myuntypeddatefield"]).toshortdatestring()
or
datetime.parse(g[0]["myuntypeddatefield"].tostring()).toshortdatestring()
ultimately, better cast or parse? all!
if g[0]["myuntypeddatefield"] datetime object, cast better choice. if it's not datetime, have no choice use parse (you invalidcastexception if tried use cast)
Comments
Post a Comment