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 6335425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:51:22+00:00 2026-05-24T18:51:22+00:00

Reading C# In Depth, 2nd edition , section 2.1.2 on combining and removing delegates.

  • 0

Reading C# In Depth, 2nd edition, section 2.1.2 on combining and removing delegates.

The subsection title states that “delegates are immutable” and that “nothing about them can be changed.” In the next paragraph, though, it talks about using constructs like

x += y;

where x and y are variables of compatible delegate types.

Didn’t I just change x? Or does the immutability part deal with when x is disposed of when I do this (i.e., immediately)?

  • 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. Editorial Team
    Editorial Team
    2026-05-24T18:51:23+00:00Added an answer on May 24, 2026 at 6:51 pm

    That’s like doing:

    string x = "x";
    string y = "y";
    
    x += y;
    

    Strings are immutable too. The code above not changing the string objects – it’s setting x to a different value.

    You need to differentiate between variables and objects. If a type is immutable, that means that you can’t change the data within an instance of that type after it’s been constructed. You can give a variable of that type a different value though.

    If you understand how that works with strings, exactly the same thing is true with delegates. The += actually called Delegate.Combine, so this:

    x += y;
    

    is equivalent to:

    x = Delegate.Combine(x, y);
    

    It doesn’t change anything about the delegate object that x previously referred to – it just creates a new delegate object and assigns x a value which refers to that new delegate.

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

Sidebar

Related Questions

I'm reading the book 'C# in Depth, 2nd Edition' of Jon Skeet. He said
So I started reading Jon Skeet's 2nd edition of C# in depth and kind
I'm currently reading Jon Skeet's C# in depth 2nd edition and the following question
I have been studying DDD in-depth on my own time; reading everything about it
I am reading through Jon Skeet's C# in Depth, first edition (which is a
I've been reading Jon Skeet's C# In Depth: Second Edition and I noticed something
I've been investigating the out keyword in C# after reading the section about it
I know next to nothing about RegEx, even after reading a few tutorials :\
While reading "C# in Depth" I was going through the section titled "Reference types
Reading MSDN (and other sources) about custom report items (CRI) for reporting services 2005.

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.