Store a reference to an object
<p>A bit of a weird question but I was wondering anyone could help...</p>

<p>In C++, I could do something like this</p>

<pre><code>class MyOtherClass
{
     private:
         MyLogger* logger;
     public:
         MyOtherClass (MyLogger* logger)
              : logger (logger)
         {}
};

class MyClass
{
     private:
         MyLogger* logger;
     public:
         MyClass (MyLogger* logger)
              : logger (logger)
         {}
};

int main (int c, char** args)
{
    MyLogger* logger = new MyLogger ();
    /* Code to set up logger */
    MyOtherClass* myOtherClass = new MyOtherClass (logger);
    MyClass* myClass = new MyClass (logger);
}
</code></pre>

<p>So that each of the other objects (myOtherClass and myClass) would contain a pointer to logger, so they would be calling the same logger class. However, how would I achieve the same thing in C#? Is there a way to store a reference or pointer to a global object - I'm guessing that in C# if I do something like</p>

<pre><code>public class MyClass
{
     private MyLogger logger = null;

     public MyClass (MyLogger _logger)
     {
         logger = _logger;
     }
};
</code></pre>

<p>that its actually assigning the class variable logger to a copy of _logger? Or am I'm mixing things up :S</p>

<p>Any help is very much appreciated, and thank you in advance!</p>
