troubleshooting Question

References and Value types

Avatar of Sandra-24
Sandra-24 asked on
5 Comments1 Solution268 ViewsLast Modified:
Since System.Drawing.Point is a struct, you cannot do this:

control.Location.X = 10;

Instead you can do:

control.Location = new Point(10,control.Location.Y);


Point loc = control.Location;
loc.X = 10;
control.Location = loc;

Both of which are irritating and harder to understand at a glance.

Is there a better alternative to modifying a member of a value type?

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros