C# 字符串转化为时间格式

来源:互联网 发布:外国人看中国网络支付 编辑:程序博客网 时间:2024/06/06 02:16
[csharp] view plaincopyprint?
  1. DateTimePicker dtp = new DateTimePicker();  
  2.  string time = dataGridView_EquipDetailInfo.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();  
  3. //上句得到的字符串格式是2010/2/2 0:00:00或 2010/12/2 0:00:00或 2010/2/22 0:00:00等。  
  4. string[] sArray = time.Split(' ');//以空格为界分割字符串;  
  5.  dtp.Value = DateTime.Parse(sArray[0]);  

原创粉丝点击