I want to use c# Point type as a reference type (it is a struct). I thought of having a class CPoint, which would contain a Point member. Is there any way to raise the members of the Point to act as members of the Cpoint. I am trying to avoid
cpoint.point.X;
cpoint.point.Y;
I would like to do
cpoint.X;
cpoint.Y;
as well as keep all the conversions, operators, Empty, etc.
Can this easily be done?
If you need it to act like a reference type then use the ref keyword. It will allow you to pass by reference. With this you will get all of the performance benefits from it being a struct, as well as knowing specifically when you expect it to act like a reference. You can also use the out keyword to return a parameter by reference.
If you need it to be able to represent null then use a
Nullable<T>If you simply want to access is like
foo.MyPoint.Xthen declare it as a field like so: