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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:26:26+00:00 2026-05-28T16:26:26+00:00

Is there much difference between these 2 if the manipulation is identical? In example

  • 0

Is there much difference between these 2 if the manipulation is identical? In example 1, a reference to an object is passed, and object is manipulated. In example 2, a reference to an object is passed, the object is manipulated, and then… The same reference is returned?

static void Foo(SomeReferenceType t)
{
    //Do something with t
}

static SomeReferenceType Foo(SomeReferenceType t)
{
    //Do same thing with t
    return t;
}

Bar bar = new Bar();

//Does this
Foo(bar);
//Do the same thing as this
bar = Foo(bar);
  • 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-28T16:26:26+00:00Added an answer on May 28, 2026 at 4:26 pm

    The latter allows for chaining methods in a fluent type interface, but it can hide the fact that the object is being manipulated. It’s not very common to manipulate an object that’s being passed that way because it can confuse consumers of the method when their objects come back mutated. What you might do is clone the object, manipulate it, and then return the manipulated clone. This leaves the object in the initial reference intact.

    In the former, the consumer is passing a variable and saying, “Dear method, please take this variable and do whatever you want with it including potentially pointing it at a new memory address.” Thus, the developer knows that the state passed in may be manipulated.

    By the way, I think you should read this: http://msdn.microsoft.com/en-us/library/0f66670z(v=vs.71).aspx

    When I interview potential developers, I ask a lot of questions about passing reference and value types by reference and by value. I’ve interviewed developers for very senior level positions who don’t understand this but I think it’s fundamental to C# development.

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

Sidebar

Related Questions

Is there really that much of a difference between the performance of Vector and
Is there much difference between those two and which one is preferably to use?
In which cases would you use which? Is there much of a difference? Which
There's so much hype about ASP.NET MVC these days, but the truth is that
What is the difference between these two forms of a string variable in C
Is there a large difference between the SSCLI 2.0 and .NET, I know that
seam actually proxies every class for interception. is there a difference between proxied classes
Is there a difference between using one method over the other. You can either
There are many question posted about getting the difference between two dates in Oracle.
I make lot of dealing with RFID cards. As much as there are different

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.