First of all I am new to C# programming.
I read the parameter of
ImageObj.getBounds(ref GraphicsUnit unit);
When I tried this,
ImageObj.getBounds(ref GraphicsUnit.Pixel);
I still got the error. But this seemed to work perfectly fine.
GraphicsUnit u = GraphicsUnit.Pixel;
ImageObj.getBounds(ref u);
What is the difference between the two and how is the first wrong? Thank You.
GraphicsUnit.Pixel
is a property, you can not pass properties with ref
/out
parameters in C#. It's because ref
/out
is like pointer to pointer in other languages but property is not a variable - it's a 2 methods: getter and setter, so, you can't pass a pointer to pointer to value because you haven't value itself.
Added:
Ok, GraphicsUnit.Pixel
actually is an enum
member - you also can't pass it with ref
/out
parameters because it's a constant.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With