I want to pass a reference type by value to a method in C#. Is there a way to do it.
In C++, I could always rely on the copy constructor to come into play if I wanted to pass by Value. Is there any way in C# except: 1. Explicitly creating a new object 2. Implementing IClonable and then calling Clone method.
Here's a small example:
Let's take a class A in C++ which implements a copy constructor.
A method func1(Class a), I can call it by saying func1(objA) (Automatically creates a copy)
Does anything similar exist in C#. By the way, I'm using Visual Studio 2005.