473,396 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Class private to a namespace

Hello all,

Is there a way to make a class private to the namespace so that other
classes in the namespace can see and use it but noone outside a namespace
can see or use it?

Feel free to send me to links to read, I just cannot seem to find anything
about this, maybe it's not possible.

Thanks in advance, jmy
Feb 10 '07 #1
5 3546
JamesO wrote:
Is there a way to make a class private to the namespace so that other
classes in the namespace can see and use it but noone outside a namespace
can see or use it?
Use a convention one namespace = one assembly and use internal
access modifier.

Arne
Feb 10 '07 #2
Access Modifiers for classes

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

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.
--
Regards JJ (UWA)

"JamesO" <jm*****@hotmail.comwrote in message
news:uc**************@TK2MSFTNGP05.phx.gbl...
Hello all,

Is there a way to make a class private to the namespace so that other
classes in the namespace can see and use it but noone outside a namespace
can see or use it?

Feel free to send me to links to read, I just cannot seem to find anything
about this, maybe it's not possible.

Thanks in advance, jmy
Feb 11 '07 #3
j1mb0jay <ja**@aber.ac.ukwrote:
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 - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 11 '07 #4

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
j1mb0jay <ja**@aber.ac.ukwrote:
>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 - <sk***@pobox.com>
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.

Feb 11 '07 #5

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:eM******************************@comcast.com. ..
>
"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP************************@msnews.microsoft.c om...
>j1mb0jay <ja**@aber.ac.ukwrote:
>>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 - <sk***@pobox.com>
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.
Oops, sorry, didn't realize I was posting this in the C# group. I think
Friend is called [internal], and ProtectedFriend is [protected internal]

Robin S.
Feb 11 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Not Available | last post by:
On the host server: namespace JCart.Common public class JCartConfiguration : IConfigurationSectionHandler private static String dbConnectionString; public static String ConnectionString { get...
10
by: Opa | last post by:
I have tried for two days to solve this problem with no luck. I have a singleton class which has some events declared. When I inherit from this class the events don't seem to come along with it....
8
by: StillStuckOnJava | last post by:
I'm using visual studio to create a web application, but I'm having trouble using a few classes that I've defined: public class tank { public tank() { } public float depth; public float...
7
by: rbeyea | last post by:
I am writing a DLL (DLL1) that is wrapping another DLL (DLL2). I need to extract the information returned from DLL2 and pass it out to the Client application this is using DLL1. DLL2 returns...
12
by: Michael Maes | last post by:
Hello, I have a BaseClass and many Classes which all inherit (directly) from the BaseClass. One of the functions in the BaseClass is to (de)serialize the (inherited) Class to/from disk. ...
3
by: tuanhoanganh | last post by:
My program has class's name same namespace 's name. Ex namespace clsvoucher public class clsvoucher .......... end class end namespace Can I use Dim a as clsvoucher or I must use Dim a as...
16
by: tshad | last post by:
This is a little complicated to explain but I have some web services on a machine that work great. The problem is that I have run into a situation where I need to set up my program to access one...
1
by: learning | last post by:
Hi how can I instaltiate a class and call its method. the class has non default constructor. all examples i see only with class of defatul constructor. I am trying to pull the unit test out from...
20
by: tshad | last post by:
Using VS 2003, I am trying to take a class that I created to create new variable types to handle nulls and track changes to standard variable types. This is for use with database variables. This...
6
by: Grok | last post by:
In writing a class library, one of the classes should only ever be instantiated once, and its object should be accessible to every other class in the library. How can I do that? To provide some...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.