Hi,
I have some trouble with "property". I currently have a managed object with a set of properties, which acts as a layer on top of another one, in order to display some informations in a property grid.
When I create a simple property, like "property float Depth;" it works fine. Then, if I write :
property float Depth {
float get(void) { m_Depth = 1.0f; return(m_Depth); }
}
It also works fine. But the following doesn't work, and I don't understand why :
property float Depth {
float get(void) { m_Depth = this->GetDepth(); return(m_Depth); }
}
float GetDepth(void) { return(1.0f); }
Instead of showing 1 in the property tab, it show : "Object reference not set to an instance of an object."
I really don't understand why this happens. Is there something wrong with my code

Question about properties
cortega
Strange. What compiler are you using What settings do you have This compiles without problem for me:
ref class foo
{
float m_Depth;
public:
property float Depth {
float get(void) { m_Depth = this->GetDepth(); return(m_Depth); }
}
float GetDepth(void) { return(1.0f); }
};
Scott Bruhnsen
bhavener
The "this" keyword doesn't change anything.
And I'm using VS2005 Express. But it's not a compilation problem, it compiles just fine. The "Object reference not set to an instance of an object." is what appears in the property tab during execution (instead of the value of m_Depth)
As soon as I use a function the the get() method, the property tab only show the "Object reference ..." instead of the actual value I'm returning ... but unfortunately, the documentation doesn't say anything about that.
Anyone has an idea
Paul Siu