Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to know difference between class and public class.
Posted
Comments
Nagy Vilmos 13-Jun-11 4:41am    
Richard and Abhinav have answered this for you.

See here[^] for Java. Other languages you could probably find for yourself.
 
Share this answer
 
Comments
Nagy Vilmos 13-Jun-11 4:41am    
Correct answer
In C#, a class by default has internal access (i.e. this class is only visible within the assembly).
A public class will have access in the assembly it is part of and all other assemblies where it is referenced.
 
Share this answer
 
Comments
Nagy Vilmos 13-Jun-11 4:40am    
Correct answer
A class has default modifiers as Internal.So if u declare the class E.g
class ABC
It will be Consider as a
Internal Class ABC
So,the Scope of that class is within the Assembly only.....
But,When u declare class like
Public Class ABC
then the scope of the class is Accessible within Whole the application whether its is in same Assembly or not.
 
Share this answer
 
v2
Comments
parmar_punit 14-Jun-11 7:57am    
good one kaushal, my 5
In C# if you write

class A


then it is equivalent to

internal class A


hence we can say that internal is the default access modifier for a class. means members are accessible only within files in the same assembly.

and
public class A


Public access is the most permissive access level. There are no restrictions on accessing public members.
 
Share this answer
 
for best solution
see this this Link
 
Share this answer
 
The uses of Public depends on your requirement, what you wanna do with your class,
and it differ language to language (C++, C#, Java etc..)

please be clear with your question.
 
Share this answer
 
if u don`t provide any access specifier then by default it is Private and to set the class as public ,u have to set public before class.
 
Share this answer
 
Comments
BobJanova 3-Jun-11 9:05am    
True for C++, not for classes in C#. You should specify the language when answering a question like this.
NandaKumer 3-Jun-11 9:41am    
Who teach you this Mr "Team Leader" ? This is quite wrong for C#

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900