I’m trying to save a button’s location in a variable, but I have no idea how to do it.Since the code shows the x and the y of the button, can I also save both x and y separately?
Console.WriteLine(button.Location);
<X=100,Y=100>
I want it to save the X value in var1, and Y value in var2.
You can save it as a single
Pointor as two different integers:You can then restore the position like this:
Note:
Pointis astruct(value type) so changinglocationwill not changebutton.Location. In other words this will have no effect:You’d need to do this:
or