Re: Class private to a namespace

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Jon Skeet [C# MVP]" <skeet@xxxxxxxxx> wrote in message
news:MPG.2039623d9a907ac798d84d@xxxxxxxxxxxxxxxxxxxxxxx
j1mb0jay <jap6@xxxxxxxxxx> wrote:
Access Modifiers for classes

public - class visible everywhere.
default - only access from same package.

No, that's "access from same assembly". It's equivalent to writing
"internal". .NET has no notion of package-level access. (.NET doesn't
have packages, either - Java does, and there the default is indeed
package access.)

These are the only two options I am aware of for a class, I'm sure the
protected modifier is only available for methods and attributes.

Private and protected are available for nested types (and private is
the default in that situation).

--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Here's some definition for the OP. This is from Tim Patrick's
"Start-to-Finish VB2005" book. I think that he's looking for is "Friend".

Public -- available everywhere. You can write an app or component that
exposes its types to code beyond itself.

Private -- private variables can be used by any member or procedure w/i the
type. Each instance of a class contains its own version of the variable. If
you derive a new class from a base class that includes a private variable,
the code in that derived class will have no access at all to that Private
variable.

Protected -- like Private, but code in derived classes can also access
them. You can only use this keyword in a class definition, not a structure
or a module.

Friend -- Private to an assembly. They can be used by any code in their
related class/type, but also by any code anywhere in the same assembly.

ProtectedFriend -- Can only be used in classes. Combines all features of
Friend and Protected.

Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.



.



Relevant Pages

  • Re: Class private to a namespace
    ... default - only access from same package. ... Private and protected are available for nested types (and private is ... Private -- private variables can be used by any member or procedure w/i ... ProtectedFriend -- Can only be used in classes. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Proper program structure
    ... type Car is limited private; ... define each type in a separate package. ... package body Cars.Gear_Box is ...
    (comp.lang.ada)
  • Re: Indirect visibility of private part in child packages
    ... an indirect visibility of a private part. ... This can be reduced to three package ... conversion) should work, and it's a compiler bug if that is rejected. ... even if the inheritance comes ...
    (comp.lang.ada)
  • OO problem: Performing actions on messages (very long, sorry)
    ... I'm new to Ada. ... action shall override a field in a message. ... package M1_Float_Override_Action is new Action.Override ... type Instance is abstract tagged private; ...
    (comp.lang.ada)
  • Re: Private primitive operations available to entire package hierarchy. Can it be done?
    ... > class name would possibly be ok in the private part of the root package ... Putting all the other primitives I need to be private from ... point of the registration package (clearly it knows about the type ...
    (comp.lang.ada)