
On the top it says, “Gets or sets…”, so then why is it not letting me change it?
On the top it says, Gets or sets …, so then why is it
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can’t do this because although
Margin.Leftgets or sets, it’s not used like a variable. Just likePadding.As you may notice,
Margin(as forPadding) is a property andThicknessis its value. So, when you sayyou are only editing a copy (
Margin) becauseMarginreturns a struct (Thickness) . That’s why you receive an error. The changes are not saved because it’s a copy!Basically, although you can change the value of
Object.Margin.Leftto a specific value yet it wouldn’t save/change the objectMarginproperty and that’s why you get an error.For example
We can NOT say
but we can say
This means that, because
Marginis a property, you are not allowed to change itsThicknessdirectly.Alternatively, you can use the following which I believe to be easier to set a
Marginof an objectThanks,
I hope you find this helpful 🙂