Click here to Skip to main content
12,827,807 members (45,681 online)
Rate this:
Please Sign up or sign in to vote.
See more: ASP.NET
can anyone explain this code line by line..i am a fresher i am not able to understand this code.
public DateTime ConvToDate(string dateString)

        DateTime result;

        string[] a = new string[] { "dd/MM/yyyy", "MM/dd/yyyy", "MM/dd/yy", "ddMMMyyyy", "dMMMyyyy","dd-MM-yyyy","MM-dd-yy","MMM dd" };
        result = DateTime.ParseExact(dateString, a, System.Globalization.CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.None);
        return result;

[Edit]Code block added[/Edit]
Posted 17-Feb-13 8:05am
Updated 17-Feb-13 8:06am
aspnet_regiis -i 17-Feb-13 13:20pm
Copy pasting does not work always.. You need to study the basics first..Google is only for help..Not to work for you
Sergey Alexandrovich Kryukov 17-Feb-13 14:01pm
This is not a good question. Why anyone should explain you the code written who knows why by who knows who? You can pick up any garbage; why explaining it? You should ask about your own code.
Mohamed Mitwalli 17-Feb-13 14:22pm
Agree with you SA .
Sergey Alexandrovich Kryukov 17-Feb-13 14:27pm
...what makes sense is looking at the documentation on the API spotted in a code sample if OP gets interest in it, but it would not require asking question, Google (or something, like MSDN search) would be more than enough).

Thank you, Mohamed.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

It is clearly explained by the DateTime.ParseExact documentation[^]: the code will try to parse the content of dateString variable using the given formats (that is the content of a array) in the given sequence.
Sergey Alexandrovich Kryukov 17-Feb-13 14:02pm
My 5, but I would avoid asking such questions at all; please see my comment to the question.
div19 17-Feb-13 19:52pm
pallini thank you..sorry all.being a fresher.. i was not able to understand that's the reason asked like know about date convertion,can anyone send me where to study.
Sheikh Muhammad Haris 17-Feb-13 23:30pm
Good Pallini. +5
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

pallini......thank you..atleast u there to help me...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170326.1 | Last Updated 17 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100