I have created a custom Point class in C#, because the regular Point class doesn't have a lot of the functions I need for it. The problem that I face, is that when I create a new custom Point class, and then create another variable to represent that newly created class, they are assigned the same addresses in memory. I remember to change this in C++ you had to use & and *, but in C# I don't know how to do this.
Here's an example of the problem I'm facing
public string Example()
{
CustomPoint pt = new CustomPoint(0, 0);
CustomPoint ptbuf = pt;
ptbuf.X = 100;
return(pt.X.ToString()); // returns the value of 100, instead of 0, which it should be
}
And this is what should happen, and what does happen with a normal Point class
public string Example2()
{
Point pt = new Point(0, 0);
Point ptbuf = pt;
ptbuf.X = 100;
return (pt.X.ToString()); // returns the value 0
}
Also, here is the part of the CustomPoint class I've made that isn't working right.
public class CustomPoint
{
public float X { get; set; }
public float Y { get; set; }
}
Thanks for your help.