PDA

View Full Version : error: System.StackOverflowException



MMStudent
جمعه 06 فروردین 1389, 11:51 صبح
با سلام و تبریک سال نو من در بر نامه خودم با خطای System.StackOverflowException رو بروشدم . زمانی که می خاستم persiandate=value رو مقداد دهی کنم اون در loop بی پایان می افته .و خطای An unhandled exception of type 'System.StackOverflowException' occurred in clinic.model.DLL را می دهد.
کد بر نامه:





protected void Button1_Click(object sender, EventArgs e)
{
pesiandate objpesiandate = new pesiandate();
Customer objcustomer = new Customer();
objcustomer .persiandate= objpesiandate.tody ();
}
..............



public class persiandate
}
public string tody()
{


PersianCalendar pc = new PersianCalendar();
DateTime now = DateTime.Now;
string year = pc.GetYear(now).ToString();
string month = pc.GetMonth(now).ToString();
string day = pc.GetDayOfMonth(now).ToString();
if (month.Length < 2)
month = "0" + month;
if (day.Length < 2)
day = "0" + day;
return year+"/" +month+"/" +day ;
.................


public class customer
}
public string persiandate
{


get
{
return persiandate;
}



set
{
persiandate = value;


}
{

{

exlord
جمعه 06 فروردین 1389, 12:17 عصر
public string persiandate
{
get;
set;
}

و یا

private string _persiandate;
public string persiandate
{
get { return _persiandate; }
set { _persiandate = value;}
}