Null Exception in Program
<p>I have a program like this</p>

<pre><code>    class Program
    {
        static void Main(string[] args)
        {
            test objtest = new test();
            objtest.Name = "vikas";
            Test(objtest);
            //objtest = null; when I uncomment this line it shows me exception
            Console.WriteLine(objtest.Name);
            Console.ReadLine();
        }

        private static void Test(test objtest)
        {
            objtest.Name = "chetan";
            objtest = null;
        }
    }

    class test
    {
        private string _Name = string.Empty;
        public string Name
        {
            get
            {
                return _Name;
            }
            set
            {
                _Name = value;
            }
        }
    }
</code></pre>

<p>Output:
chetan</p>

<p>Second program:</p>

<pre><code>    class Program
    {
        static void Main(string[] args)
        {
            test objtest = new test();
            objtest.Name = "vikas";
            Test(objtest);
            objtest = null;
            try
            {
                Console.WriteLine(objtest.Name);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException + " " + ex.Message);
            }

            Console.ReadLine();
        }

        private static void Test(test objtest)
        {
            objtest.Name = "chetan";
            objtest = null;
        }
    }

    class test
    {
        private string _Name = string.Empty;
        public string Name
        {
            get
            {
                return _Name;
            }
            set
            {
                _Name = value;
            }
        }
    }
</code></pre>

<p>Output: </p>

<blockquote>
  <p>Object reference not to set an instance of object</p>
</blockquote>

<p>Why?
When I set <code>objtest = null;</code> in Test it shows me the value,  but when I set null in same it shows me error.</p>

<p><em>Added after @kmatyaszek post:</em></p>

<p>In first program </p>

<pre><code>static void Main(string[] args)
        {
            test objtest = new test();
            objtest.Name = "vikas"; // **I am assigning this value**
            Test(objtest);
            //objtest = null; when I uncomment this line it shows me exception
            Console.WriteLine(objtest.Name);
            Console.ReadLine();
        }

        private static void Test(test objtest)
        {
            objtest.Name = "chetan";
            objtest = null;
        }
</code></pre>

<p>Why it is displaying "chetan" not "vikas"??</p>
