Interviews5 answers
Differentiate bw the public and private ?
5 Answers
Public can be used everywhere in the application.
Private can be access-able only within the scope.
Ayappan AlagesanPosted Feb 11, 2017, 8:37 PM EST
public can accessible throughout the application
private can access only within the class
Manoj Kumar DuraisamyPosted Jan 2, 2017, 8:53 PM EST
.Net has five access Specifiers
Public -- Accessible outside the class through object reference.
Private -- Accessible inside the class only through member functions.
Protected -- Just like private but Accessible in derived classes also through member
functions.
Internal -- Visible inside the assembly. Accessible through objects.
Protected Internal -- Visible inside the assembly through objects and in derived classes outside the assembly through member functions.
Subhashkumar YadavPosted Dec 18, 2016, 11:27 PM EST
private is available only in the defined class where as public is available to entire project
Sunil BabuPosted Apr 2, 2016, 3:49 AM EDT
public :
The type or member can be accessed by any other code in the same assembly or another assembly that references it.
private :
The type or member can only be accessed by code in the same class or struct.
Rafnas T PPosted Jan 26, 2016, 7:48 PM EST





