Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 115559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:02:20+00:00 2026-05-11T03:02:20+00:00

Lets consider that I have a public property called AvatarSize like the following, public

  • 0

Lets consider that I have a public property called AvatarSize like the following,

public class Foo {   ...    public Size AvatarSize   {     get { return myAvatarSize; }     set { myAvatarSize = value; }   }    ... } 

Now if a target class wants to set this property, then they need to do it the following way,

myFoo.AvatarSize = new Size(20, 20);  //this is one possible way 

But if I try to set it like this,

myFoo.AvatarSize.Height = 20;  //.NET style myFoo.AvatarSize.Width = 20;  //error 

the compiler get me an error stating that it cannot modify the return values. I know why it happens, but I would like it to support the second way also. Please help me with a solution.

P.S. Sorry if the title is absurd

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:02:21+00:00Added an answer on May 11, 2026 at 3:02 am

    Size is a structure. Being a ValueType it’s immutable. If you change it’s property like that, it will only modify an object instance in the stack, not the actual field. In your case AvatarSize property can only be set using a struct constructor: new Size(20, 20).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 74k
  • Answers 74k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Remember, Objective-C is a superset of C, so typecasting works… May 11, 2026 at 2:15 pm
  • added an answer Access used to have its own incompatible version of SQL,… May 11, 2026 at 2:15 pm
  • added an answer It stuck me that most of the answers so far… May 11, 2026 at 2:15 pm

Related Questions

Consider this problem: I have a program which should fetch (let's say) 100 records
Consider: print $foo, AAAAAAAA, $foo, BBBBBBBB; Let's say I want to use this code
Lets say I have a Dictionary object: Dictionary myDictionary<int, SomeObject> = new Dictionary<string, SomeObject>();
Lets say that you have websites www.xyz.com and www.abc.com. Lets say that a user
Surprisingly I was only able to find one previous question on SO about this
Lots of developers think that testing private methods is a bad idea. However, all
Suppose I have a collection (be it an array, generic List, or whatever is
If I override Equals and GetHashCode, how do I decide which fields to compare?

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.