+ 2

Is private encapsulation used by default?

I have wrote the "private" keyword for the class, where I have Main function, and compiler returned me an error. Why? As I remembered, when is no one encapsulation keywords is used, a class or method is automatically private.

11th Jan 2018, 9:04 PM
Xeight Bive
Xeight Bive - avatar
2 Antworten
+ 6
default access modifier is private for class members not for the class , I have read lots of texts about c# and "as I understood" is internal
11th Jan 2018, 9:11 PM
Rabee Abbas
Rabee Abbas - avatar
+ 2
firstly, access modifier is for the class members. it is used to eradicate the data clash between different classes. thereby, private and protected members of different class can have same name as they are not accessible for outside. secondly, a member in the class is by default private not the class. THINK SIMPLY : if a class is private, it will be inaccessible from any part of the program. there is no concept like private class.thank u
14th Jan 2018, 6:28 PM
Mahmud Farabi
Mahmud Farabi - avatar