string s = "2005-2-21"; Regex reg = new Regex(@"(?<y>\d{4})-(?<m>\d{1,2})-(?<d>\d{1,2})",RegexOptions.Compiled);
Match match = reg.Match(s); int year = int.Parse(match.Groups["y"].Value); int month = int.Parse(match.Groups["m"].Value); int day = int .Parse(match.Groups["d"].Value); DateTime time = new DateTime(year,month,day);
①
欢迎转载我网所刊信息,请注明“来源:E天下网络”。
② 凡本网注明“来源:XXX(非E天下网络)”的作品,均转载自其它媒体,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如因作品内容、版权和其它问题需要同本网联系的,请在30日内进行。
※联系方式:Airtofly@163.com