定义CLASS和方法的默认缺省修饰符!


Posted on October 13, 2008


定义一个CLASS和方法时,在它们前不加修饰符,默认的缺省修饰符是有所区别的,class是public的,但是其成员是pravite的,切记~

using System;
using System.Collections.Generic;
using System.Text;
using extend;

namespace inside
{
    class Program
    {
        static void Main(string[] args)
        {
            Class1 a = new Class1();
            a.publicprintScreen();
        }
    }
}
 

using System;
using System.Collections.Generic;
using System.Text;

namespace extend
{
    class Class1
    {
        void printScreen()
        {
            Console.WriteLine("This is an Extend class!");
        }
        public void publicprintScreen()
        {
            Console.WriteLine("This is a public method in an  Extend class!");
            printScreen();
        }
    }
}
 

在线学习答案查询入口
微信扫一扫
微信扫码联系