R
RayLopez99
For some reason, I spent a good part of an hour before I caught this
mistake. And I thought I knew everything there is to know about C#,
sorry Arne.
Truth is, I've used the second "incorrect" version of properties, I
swear, and did not have a problem before, but with Linq you get a
runtime error System.StackOverflowException (it compiles fine
however).
Anyway, problem solved.
RL
Properties when used with Linq queries should obey this format.
CORRECT:
private int productXYZ;
public int ProductXYZ
{
get { return productXYZ; }
set { productXYZ = value; }
}
INCORRECT:
private int productXYZ;
public int ProductXYZ
{
get { return productXYZ; }
set { ProductXYZ = value; } //error
}
INCORRECT:
private int productXYZ;
public int ProductXYZ
{
get { return ProductXYZ; } //error
set { productXYZ = value; }
}
http://stackoverflow.com/questions/1437791/overloading-getter-and-setter-causes-stackoverflow-in-c
http://stackoverflow.com/questions/...e-always-throws-system-stackoverflowexception
mistake. And I thought I knew everything there is to know about C#,
sorry Arne.
Truth is, I've used the second "incorrect" version of properties, I
swear, and did not have a problem before, but with Linq you get a
runtime error System.StackOverflowException (it compiles fine
however).
Anyway, problem solved.
RL
Properties when used with Linq queries should obey this format.
CORRECT:
private int productXYZ;
public int ProductXYZ
{
get { return productXYZ; }
set { productXYZ = value; }
}
INCORRECT:
private int productXYZ;
public int ProductXYZ
{
get { return productXYZ; }
set { ProductXYZ = value; } //error
}
INCORRECT:
private int productXYZ;
public int ProductXYZ
{
get { return ProductXYZ; } //error
set { productXYZ = value; }
}
http://stackoverflow.com/questions/1437791/overloading-getter-and-setter-causes-stackoverflow-in-c
http://stackoverflow.com/questions/...e-always-throws-system-stackoverflowexception