It’s pretty simple actually:
// I'm assuming that 1391 is the year, 4 is the month and 7 is the day
DateTime dt = new DateTime(1391, 4, 7, persianCalendar);
// Now use DateTime, which is always in the Gregorian calendar
When you call the DateTime constructor and pass in a Calendar, it converts it for you – so dt.Year would be 2012 in this case. If you want to go the other way, you need to construct the appropriate DateTime then use Calendar.GetYear(DateTime) etc.
Short but complete program:
using System;
using System.Globalization;
class Test
{
static void Main()
{
PersianCalendar pc = new PersianCalendar();
DateTime dt = new DateTime(1391, 4, 7, pc);
Console.WriteLine(dt.ToString(CultureInfo.InvariantCulture));
}
}
That prints 06/27/2012 00:00:00.