Answer: Using DateTime format,we can get Year part from any given string date.We have to pass format in ToString method of DateTime class as yyyy.
For Example:-
string year_part = Convert.ToDateTime(date).ToString("yyyy");
Output would be :- 2013.
Asked In: Many Interviews |
Alert Moderator