Public in C#

Since the member 'name' in program2 class is declared as public, it can be accessed in program1 class.

using System;
using System.IO;

namespace forgetCode
{
    class program1
    {
        static void Main(string[] args)
        {
            program2 obj = new program2();
            string new_name = obj.name;
            Console.WriteLine(new_name);

        }
    }

   class program2
    {
       public string name = "Forget Code";
    }
}



Output:
Forget Code

..