In C#, what is the difference between public, private, protected, and having no access modifier?

前端 未结 16 2761
盖世英雄少女心
盖世英雄少女心 2020-11-22 01:12

All my college years I have been using public, and would like to know the difference between public, private, and protected

16条回答
  •  醉话见心
    2020-11-22 02:17

    public - can be access by anyone anywhere.
    private - can only be accessed from with in the class it is a part of.
    protected - can only be accessed from with in the class or any object that inherits off of the class.

    Nothing is like null but in VB.
    Static means you have one instance of that object, method for every instance of that class.

提交回复
热议问题