You can change what foo
points to using y
:
Foo foo = new Foo("1");
void Bar(ref Foo y)
{
y = new Foo("2");
}
Bar(ref foo);
// foo.Name == "2"
More Related Contents:
- Passing Objects By Reference or Value in C#
- C# pass by value vs. pass by reference
- Passing objects by reference vs value
- How do I modify a pointer that has been passed into a function in C?
- Why use the ‘ref’ keyword when passing an object?
- Assigning out/ref parameters in Moq
- SqlCommand Parameters Add vs. AddWithValue [duplicate]
- Object cannot be cast from DBNull to other types
- ‘UserControl’ constructor with parameters in C#
- How to pass parameters to another process in c#
- In C#, what happens when you call an extension method on a null object?
- Default parameter for value must be a compile time constant?
- c# Using Parameters.AddWithValue in SqlDataAdapter
- MySqlCommand Command.Parameters.Add is obsolete
- How to bind parameters via ODBC C#?
- Function Overloading Based on Value vs. Const Reference
- Use of “this” keyword in formal parameters for static methods in C#
- Is there a reasonable approach to “default” type parameters in C# Generics?
- Interesting “params of ref” feature, any workarounds?
- thread with multiple parameters
- When is using the C# ref keyword ever a good idea?
- What exactly is the difference between “pass by reference” in C and in C++?
- Does C++ pass objects by value or reference?
- Performance cost of passing by value vs. by reference or by pointer?
- How does C# choose with ambiguity and params
- Can I have a variable number of generic parameters?
- C# params object[] strange behavior
- Append values to query string
- Can I get parameter names/values procedurally from the currently executing function?
- C++ view types: pass by const& or by value?