I use a date picker as an input for selected date. I want to convert the selected date into its equivalent Shamsi (persian) date. I tried this code:
private void button2_Click(object sender, EventArgs e)
{
string[] Gregorian = Convert.ToString(dateTimePicker1.Value.ToShortDateString()).Split('/');
PersianCalendar persian = new PersianCalendar();
label4.Text = string.Format("{0}/{1}/{2}", persian.GetYear(Convert.ToInt32(Gregorian[2]), persian.GetMonth(Convert.ToInt32(Gregorian[0]), persian.GetDayOfMonth(Convert.ToInt32(Gregorian[1])));
}
But it has red underline in Convert.ToInt32(Gregorian[1])
section. The IDE says "cannot convert from 'int' to 'system.DateTime'.
Please help me.
I tried this: