我的系统日期格式是dd-MM-yyyy(20-10-2012),我得到了日期并使用分隔符来分割日期,月份和年份.我需要转换日期格式(dd/MM/yyyy)格式是否以任何日期格式返回.
string sDate = string.Empty;
DateTime _date = DateTime.Now;
int count = 0;
string format = "dd-MM-yyyy";
sDate = dateFormat.ToString(format);
string[] Words = sDate.Split(new char[] { '-' });
foreach (string Word in Words)
{
count += 1;
if (count == 1) { Day = Word; }
if (count == 2) { Month = Word; }
if (count == 3) { Year = Word; }
}
Run Code Online (Sandbox Code Playgroud)