oop - C#: Why do I have to use the public access modifier in class's vars? -
ok, well, am beginner, so.. yeah, may stupid question. read if declare variable or object, without mentioniong access-modifier (public, private, etc.) it's automatically making having internal acess modifier (and exist anywhere in current namespace).
so why need set vars in class public them in class (such program's class of course).
because can not read? ok, joking aside. said eginner, totally normal overlook small things.
i read if declare variable or object, without mentioniong access-modifier (public, private, etc.) it's automatically making having internal acess modifier
ah, no. defaults private, not internal. defaults sensible default, , internal still allow lot of cross class accesses lead bad code practices.
Comments
Post a Comment