J
Jean Stax
Hi !
Jeffrey Richter gives the following example in his book:
struct Point {
Int32 x, y;
}
class AAA{
....
public virtual void Add(Object value);
....
}
We want to pass the variable of Point type to add method.
Now Richter writes:
From this, you can plainly see that Add takes an Object as a
parameter, indicating that Add requires a reference (or pointer) to an
object on the managed heap as a parameter. But in the preceding code,
I’m passing p a Point value type. For this code to work, the
Point value type must be converted into a true heap-managed object and
a reference to this object
must be obtained.
My queation is: how we know from this code that Add expects reference
type ?
Is it true when I modify the code as follows ? :
public virtual void Add(System.ValueType value);
Thanks
Jean
Jeffrey Richter gives the following example in his book:
struct Point {
Int32 x, y;
}
class AAA{
....
public virtual void Add(Object value);
....
}
We want to pass the variable of Point type to add method.
Now Richter writes:
From this, you can plainly see that Add takes an Object as a
parameter, indicating that Add requires a reference (or pointer) to an
object on the managed heap as a parameter. But in the preceding code,
I’m passing p a Point value type. For this code to work, the
Point value type must be converted into a true heap-managed object and
a reference to this object
must be obtained.
My queation is: how we know from this code that Add expects reference
type ?
Is it true when I modify the code as follows ? :
public virtual void Add(System.ValueType value);
Thanks
Jean