/* string fecha_act = DateTime.Now.ToString("d/MM/yy"); */
date_act = "10-12-12"
string[] splitting = date_act.Split('-');
foreach (string split in splitting)
{
MessageBox.Show(split);
}
The above code shows a date in a string. That string will be splitted into three parts.
Said that, I need to save the three parts in three differents strings.
string day_act;
string month_act;
string year_act;
I’ve tried to doing it with a counter and a switch, but it doesn’t work.
Any suggestions?
Wouldn’t this work? It’s so straightforward I suspect you’ve tried it already.
Edit
So you want alternate methods to
Split? Here are some:Use a variation of the
DateTime.Parsemethod (as mentioned in other answers).Use a regular expression.