Click here to Skip to main content
11,581,397 members (63,113 online)
Rate this: bad
good
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 7:05am
div19314
Edited 17-Feb-13 7:06am
ProgramFOX159.6K
v2
Comments
aspnet_regiis -i at 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 at 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 at 17-Feb-13 14:22pm
   
Agree with you SA .
Sergey Alexandrovich Kryukov at 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
Rate this: bad
good
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.
  Permalink  
Comments
Sergey Alexandrovich Kryukov at 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 at 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.
Sheikh Muhammad Haris at 17-Feb-13 23:30pm
   
Good Pallini. +5
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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

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

  Print Answers RSS
0 OriginalGriff 340
1 Sergey Alexandrovich Kryukov 155
2 virusstorm 114
3 Frankie-C 105
4 RyanDev 84
0 OriginalGriff 1,273
1 Sergey Alexandrovich Kryukov 895
2 Abhinav S 597
3 F-ES Sitecore 500
4 Suvendu Shekhar Giri 433


Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 17 Feb 2013
Copyright © CodeProject, 1999-2015
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