.net - I need to accept from input file and that may be of any format in C# . i need to check the format and extract year -


the format yyyymmdd not being accepted , throwing exception tried using

string year = datetime.parseexact(usedate, "yyyymmdd",               cultureinfo.invariantculture).year.tostring(); 

do need use date variable ? , how date format yyyymmdd gets processed?

i have tested , works fine

datetime temp; if (datetime.tryparseexact("20130101", "yyyymmdd", cultureinfo.invariantculture, datetimestyles.none, out temp)) {      string year = temp.year.tostring(); } 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -