Click here to Skip to main content
15,915,603 members
Home / Discussions / C#
   

C#

 
AnswerRe: how to draw listbox items with different itemheight when i selected a item Pin
Mike Hankey10-Mar-07 2:48
mveMike Hankey10-Mar-07 2:48 
QuestionMail Pin
Jijo BP9-Mar-07 17:46
Jijo BP9-Mar-07 17:46 
AnswerRe: Mail Pin
S. Senthil Kumar10-Mar-07 5:10
S. Senthil Kumar10-Mar-07 5:10 
QuestionWord Template Programming in C# Pin
satsumatable9-Mar-07 17:36
satsumatable9-Mar-07 17:36 
QuestionMethod Matching Pin
SHaroz9-Mar-07 17:20
SHaroz9-Mar-07 17:20 
AnswerRe: Method Matching Pin
S. Senthil Kumar10-Mar-07 5:13
S. Senthil Kumar10-Mar-07 5:13 
QuestionConstructors in C# Pin
Captain See Sharp9-Mar-07 15:57
Captain See Sharp9-Mar-07 15:57 
AnswerRe: Constructors in C# Pin
Scott Dorman9-Mar-07 17:31
professionalScott Dorman9-Mar-07 17:31 
It has to do with the accessibility rules in C# and the meanings of private, protected, and public methods.

From the C# Language Reference[^]

  • The intuitive meaning of public is "access not limited".
  • The intuitive meaning of protected is "access limited to the containing class or types derived from the containing class".
  • The intuitive meaning of private is "access limited to the containing type".
When a type or member M is accessed, if M is protected, the access is permitted if it occurs within the class in which M is declared, or if it occurs within a class derived from the class in which M is declared and takes place through the derived class type (Section 3.5.3).

Otherwise, if M is private, the access is permitted if it occurs within the type in which M is declared.

As described in Section 3.4, all members of a base class, except for instance constructors, destructors and static constructors, are inherited by derived types. This includes even private members of a base class. However, the accessibility domain of a private member includes only the program text of the type in which the member is declared.
So, by declaring the constructor as "private", you are limiting it's accessibility to the class in which it is declared (the "containing type"). This effectively tells the compiler that since there is no default constructor accessible from outside the class, any derived classes cannot create an instance of their base class and, therefor, cannot themselves contain constructors.

By declaring the constructor as "protected", you are limiting it's accessibility to the class in which it is declared (the "containing type") and also to any types derived from that class. This effectively tells the compiler that the child classes are able to create an instance of their base class, and, therefor, can also contain constructors.

-----------------------------
In just two days, tomorrow will be yesterday.

AnswerRe: Constructors in C# Pin
Zoltan Balazs10-Mar-07 1:59
Zoltan Balazs10-Mar-07 1:59 
GeneralRe: Constructors in C# Pin
Captain See Sharp10-Mar-07 13:42
Captain See Sharp10-Mar-07 13:42 
AnswerRe: Constructors in C# Pin
S. Senthil Kumar10-Mar-07 5:20
S. Senthil Kumar10-Mar-07 5:20 
GeneralRe: Constructors in C# Pin
Captain See Sharp10-Mar-07 13:37
Captain See Sharp10-Mar-07 13:37 
GeneralRe: Constructors in C# Pin
S. Senthil Kumar10-Mar-07 13:46
S. Senthil Kumar10-Mar-07 13:46 
GeneralRe: Constructors in C# Pin
Captain See Sharp10-Mar-07 13:51
Captain See Sharp10-Mar-07 13:51 
GeneralRe: Constructors in C# Pin
gumi_r@msn.com10-Mar-07 14:29
gumi_r@msn.com10-Mar-07 14:29 
GeneralRe: Constructors in C# Pin
Captain See Sharp10-Mar-07 13:54
Captain See Sharp10-Mar-07 13:54 
GeneralRe: Constructors in C# Pin
S. Senthil Kumar10-Mar-07 14:21
S. Senthil Kumar10-Mar-07 14:21 
QuestionState Mangement Pin
Renuka Reddy9-Mar-07 15:33
Renuka Reddy9-Mar-07 15:33 
AnswerRe: State Mangement Pin
Udhaya Kumar.D10-Mar-07 4:19
Udhaya Kumar.D10-Mar-07 4:19 
Questionadding a property to user control Pin
dino20949-Mar-07 12:57
dino20949-Mar-07 12:57 
AnswerRe: adding a property to user control Pin
Captain See Sharp9-Mar-07 16:06
Captain See Sharp9-Mar-07 16:06 
QuestionIRIS Recgonition Pin
shdelpiero9-Mar-07 11:29
shdelpiero9-Mar-07 11:29 
AnswerRe: IRIS Recgonition Pin
User 17164929-Mar-07 14:01
professionalUser 17164929-Mar-07 14:01 
QuestionColors Pin
Ranger499-Mar-07 10:42
Ranger499-Mar-07 10:42 
AnswerRe: Colors Pin
Judah Gabriel Himango9-Mar-07 10:44
sponsorJudah Gabriel Himango9-Mar-07 10:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.