Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
can anyone explain this code line by line..i am a fresher i am not able to understand this code.
C#
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
Updated 17-Feb-13 7:06am
v2
Comments
bbirajdar 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.
—SA
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.
—SA

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.
 
Share this answer
 
Comments
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.
—SA
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 this..to know about date convertion,can anyone send me where to study.
[no name] 17-Feb-13 23:30pm    
Good Pallini. +5
pallini......thank you..atleast u there to help me...
 
Share this answer
 

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


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900