White space issue when parsing datetime Options

P

parez

Hi All,

i have two accepted formats.


expectedFormats = New String() {"%M/%d/yyyy", "%M/%d/yyyy hh:mm:ss
tt"}


dt = DateTime.ParseExact(txtInpDateString.Text, expectedFormats,
culture.DateTimeFormat,
Globalization.DateTimeStyles.AllowWhiteSpaces)


and i get 05/14/200711:22:33 AM as a valid date. (Note: there is no
space between year and time) and i am pretty sure zero lenght string
is not a white space.


Please help
 
N

Nicholas Paldino [.NET/C# MVP]

Are you saying that you want the parsing to fail in that situation?
 
P

parez

Sorry about that!!
Yes i am saying it should fail
Are you saying that you want the parsing to fail in that situation?

--
- Nicholas Paldino [.NET/C# MVP]



i have two accepted formats.
expectedFormats = New String() {"%M/%d/yyyy", "%M/%d/yyyy hh:mm:ss
tt"}
dt = DateTime.ParseExact(txtInpDateString.Text, expectedFormats,
culture.DateTimeFormat,
Globalization.DateTimeStyles.AllowWhiteSpaces)
and i get 05/14/200711:22:33 AM as a valid date. (Note: there is no
space between year and time) and i am pretty sure zero lenght string
is not a white space.
Please help- Hide quoted text -

- Show quoted text -
 
J

John Vottero

AllowWhiteSpace means "be flexible with whitespace". Remove that option.

parez said:
Sorry about that!!
Yes i am saying it should fail
Are you saying that you want the parsing to fail in that situation?

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)"parez" <[email protected]>
wrote in message



i have two accepted formats.
expectedFormats = New String() {"%M/%d/yyyy", "%M/%d/yyyy hh:mm:ss
tt"}
dt = DateTime.ParseExact(txtInpDateString.Text, expectedFormats,
culture.DateTimeFormat,
Globalization.DateTimeStyles.AllowWhiteSpaces)
and i get 05/14/200711:22:33 AM as a valid date. (Note: there is no
space between year and time) and i am pretty sure zero lenght string
is not a white space.
Please help- Hide quoted text -

- Show quoted text -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top