473,396 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

PROPERTY PROBLEM

wHen i set CokSatan in my page load event it returns stack overflow..

When i try it step by step it stucks at

this.CokSatan = value; line.

what is the problem ?

class myclass : Controls.RProductList

{
public string CokSatan

{

get

{

return this.CokSatan;

}

set

{

this.CokSatan = value;
}

}

public override void GenerateSQL()

{

if (base.SQL_Top == string.Empty)

{

base.SQL = this.CokSatan ;

base.SQL = this.AddOrderBySQL(base.SQL);

base.GenerateSQL();

}

}

}

AND

private void Page_Load(object sender, System.EventArgs e)

{

myclass xclass= new myclass();

xclass.CokSatan =(Rproductlist22.getSQL(string.Empty));
Feb 6 '07 #1
3 1258
On Feb 6, 6:42 am, <in da clubwrote:
wHen i set CokSatan in my page load event it returns stack overflow..

When i try it step by step it stucks at

this.CokSatan = value; line.

what is the problem ?

class myclass : Controls.RProductList

{

public string CokSatan

{

get

{

return this.CokSatan;

}

set

{

this.CokSatan = value;

}
}

public override void GenerateSQL()

{

if (base.SQL_Top == string.Empty)

{

base.SQL = this.CokSatan ;

base.SQL = this.AddOrderBySQL(base.SQL);

base.GenerateSQL();

}
}
}

AND

private void Page_Load(object sender, System.EventArgs e)

{

myclass xclass= new myclass();

xclass.CokSatan =(Rproductlist22.getSQL(string.Empty));

Er, yes, it would.

You are returning (and setting) the actual property name. So, what is
going to happen here?

You call x.CokSatan = "This is a test";

This calls the property set function, which sets the PROPERTY CokSatan
to a string, which
of course calls the property set function, which sets the PROPERTY ..
well, you get the idea.
You are recursing things to death. What you want is this:

class myclass : Controls.RProductList
{
private string okSatanString = "";
public string CokSatan
{
get { return this.okSatanString; }
set { this.okSatanString = value; }
}
}

See the difference? One is a property name, the other is a member
variable.

matt
Feb 6 '07 #2
Your get and set accessors go to infinite recursion.

--
HTH
Stoitcho Goutsev (100)

<in da clubwrote in message news:u8**************@TK2MSFTNGP06.phx.gbl...
wHen i set CokSatan in my page load event it returns stack overflow..

When i try it step by step it stucks at

this.CokSatan = value; line.

what is the problem ?

class myclass : Controls.RProductList

{
public string CokSatan

{

get

{

return this.CokSatan;

}

set

{

this.CokSatan = value;
}

}

public override void GenerateSQL()

{

if (base.SQL_Top == string.Empty)

{

base.SQL = this.CokSatan ;

base.SQL = this.AddOrderBySQL(base.SQL);

base.GenerateSQL();

}

}

}

AND

private void Page_Load(object sender, System.EventArgs e)

{

myclass xclass= new myclass();

xclass.CokSatan =(Rproductlist22.getSQL(string.Empty));


Feb 6 '07 #3
You are referring to the property _not_ the property backing field.

This will cause a stack overflow because it is recursive.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

in da club wrote:
wHen i set CokSatan in my page load event it returns stack overflow..

When i try it step by step it stucks at

this.CokSatan = value; line.

what is the problem ?

class myclass : Controls.RProductList

{
public string CokSatan

{

get

{

return this.CokSatan;

}

set

{

this.CokSatan = value;
}

}

public override void GenerateSQL()

{

if (base.SQL_Top == string.Empty)

{

base.SQL = this.CokSatan ;

base.SQL = this.AddOrderBySQL(base.SQL);

base.GenerateSQL();

}

}

}

AND

private void Page_Load(object sender, System.EventArgs e)

{

myclass xclass= new myclass();

xclass.CokSatan =(Rproductlist22.getSQL(string.Empty));

Feb 6 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Filips Benoit | last post by:
Dear All, W2000 Office2000 Access adp SQLserver DB Problem: Adding a new property for a company in the subform. The FIRST time I Select a property in combobox CPROP_PRP_ID the subform act
13
by: Will Pittenger | last post by:
I have a Control derived class. When the parent of the control changes the control's Location property, the stack overflows. I have not found a way to find out what was on the stack when it does...
0
by: Filips Benoit | last post by:
Dear All, W2000 Office2000 Access adp SQLserver DB Problem: Adding a new property for a company in the subform. The FIRST time I Select a property in combobox CPROP_PRP_ID the subform act
0
by: Andreas Poller | last post by:
Hi, I want to customize a Property Grid in the following way: The Property Grid should show a property which value should be changed by a dropdown-listbox. For example, there is a property...
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
0
by: Brian Young | last post by:
Hi all. I'm using the Property Grid control in a control to manage a windows service we have developed here. The windows service runs a set of other jobs that need to be managed. The control...
4
by: Vivek Sharma | last post by:
Hi, I have a form in a windows application. In that form I have declared the public property InvoiceNo. I am trying to access this property from the other form. In the other form I declared...
8
by: Al | last post by:
I'd like to create Class Library in VB 2005, which has a property accessible by external programs. I decided to include 1 Class with 1 property in this project. I placed this code in Class:...
14
by: Dom | last post by:
Hi all I'm developing a control, and I need to hide some properties to the user. For example, suppose I need Text property to be completely inacessible (from a Form/Code that is into another...
1
by: berny.zamora | last post by:
Hello everyone, I have a composite control (lets call it the parent) that contains a datalist. The datalist has an ItemTemplate that contains another composite control (lets call it the child)....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.