コード例 #1
0
        static void Main(string[] args)
        {
            DemoEncap obj = new DemoEncap();

            obj.Name = "Ankita";
            obj.Age  = 21;
            Console.WriteLine("Name: " + obj.Name);
            Console.WriteLine("Age: " + obj.Age);
        }
コード例 #2
0
        static void Main(string[] args)
        {
            DemoEncap obj = new DemoEncap();

            obj.Name = "ShanshanYu";
            obj.Age  = 18;//girls are always 18!!!!

            Console.WriteLine("Name: " + obj.Name);
            Console.WriteLine("Age: " + obj.Age);
        }
コード例 #3
0
        static void Main(string[] args)
        {
            // creting object
            DemoEncap obj = new DemoEncap();

            // calls set accessor of the property Name, and pass "Ankita" as value of the standard field 'value'
            obj.Name = "Ankita";
            // calls set accessor of the property Age, and pass "21" as value of the standard field 'value'
            obj.Age = 21;
            // Displaying values of the variables
            Console.WriteLine("Name: " + obj.Name);
            Console.WriteLine("Age: " + obj.Age);
        }