Monday, July 23, 2007

Protected? Sure?

image Call me stupid, but I only recently realized, that the access-level 'protected' has a different meaning in Java than in C#.

 

Java:

image

Visibility of the members of Alpha:

Modifier Alpha Beta AlphaSub Gamma
public Y Y Y Y
protected Y Y Y N
no modifier* Y Y N N
private Y N N N

(* also called package private)

C#:

image

Visibility of the members of Alpha:

Modifier Alpha Beta AlphaSub Gamma
public Y Y Y Y
protected internal Y Y Y N
internal Y Y N N
protected Y N Y N
private * Y N N N

(* private is the default access-level for members if nothing is specified)

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...