473,395 Members | 1,730 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,395 software developers and data experts.

problem with accessrights when having a class in another class

Hello!

I access the class MyComparer in this way.
steel_post.Sort(new MeltPracDataComposition.Composition.MyComparer());

You can see the class definition for MyComparer below.
As you can see this class MyComparer in located withing class Composition
and this
class Composition is located within class MeltPracDataComposition.

Now to my problem if I use the default which I thing is internal on the
class definition for class MyComparer I get this compile error.
C:\PK\Development\Products\UTCAS\4.0\SRC\MeltPracA pplication\Dialog\Composit
ionForm.cs(456):
'MeltPracData.MeltPracDataComposition.Composition. MyComparer' is
inaccessible due to its protection level

But if I prefix the class MyComparer with the keword internal I don't get
any compile error.
As I have understood is the default on class definition always internal so
if that is the case
I wouldn't have got these compile errors when using the default.

Can somebody explain why I got compile error when using the default
especially when
the default is internal and when using the internal I don't get any compile
errors.

public class MeltPracDataComposition : MeltPracData
{
public class Composition : IComparable
{
...

class MyComparer : IComparer
{
region IComparer Members
public int Compare(object x, object y)
{
return
((Composition)x).Order.CompareTo(((Composition)y). Order );
}
#endregion
}// end class MyComparer
}// end class Composition
}//end class MeltPracDataComposition

//Tony
Aug 31 '06 #1
1 1302
Hi tony,

the default accessabilty of any class or struct member (including nestet
types) is allways private.
Only for Toplevel types (= not nested) the default is internal.

The intuitive rule is: default accessability is allways "as private as
possible".

hth

"tony" <jo*****************@telia.comschrieb im Newsbeitrag
news:O7**************@TK2MSFTNGP03.phx.gbl...
Hello!

I access the class MyComparer in this way.
steel_post.Sort(new MeltPracDataComposition.Composition.MyComparer());

You can see the class definition for MyComparer below.
As you can see this class MyComparer in located withing class Composition
and this
class Composition is located within class MeltPracDataComposition.

Now to my problem if I use the default which I thing is internal on the
class definition for class MyComparer I get this compile error.
C:\PK\Development\Products\UTCAS\4.0\SRC\MeltPracA pplication\Dialog\Composit
ionForm.cs(456):
'MeltPracData.MeltPracDataComposition.Composition. MyComparer' is
inaccessible due to its protection level

But if I prefix the class MyComparer with the keword internal I don't get
any compile error.
As I have understood is the default on class definition always internal so
if that is the case
I wouldn't have got these compile errors when using the default.

Can somebody explain why I got compile error when using the default
especially when
the default is internal and when using the internal I don't get any
compile
errors.

public class MeltPracDataComposition : MeltPracData
{
public class Composition : IComparable
{
...

class MyComparer : IComparer
{
region IComparer Members
public int Compare(object x, object y)
{
return
((Composition)x).Order.CompareTo(((Composition)y). Order );
}
#endregion
}// end class MyComparer
}// end class Composition
}//end class MeltPracDataComposition

//Tony


Aug 31 '06 #2

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

Similar topics

2
by: Marc | last post by:
Hi all, I was using Tkinter.IntVar() to store values from a large list of parts that I pulled from a list. This is the code to initialize the instances: def initVariables(self): self.e =...
2
by: endus | last post by:
I'm having some trouble getting something to work. I'm not even sure whether or not this is possible, but it *seems* like it should be. I've done a fair amount of experimenting and googling...but...
4
by: Leslaw Bieniasz | last post by:
Cracow, 20.09.2004 Hello, I need to implement a library containing a hierarchy of classes together with some binary operations on objects. To fix attention, let me assume that it is a...
0
by: Lucas, Todd | last post by:
Hello everyone! I'm having a problem with a WebControl that I'm designing for a Menu. I've been at it for about 3 weeks now, and can't seem to get around this problem. So I'm hoping that someone...
5
by: Keith Jakobs, MCP | last post by:
Hi All.... I'm having a HECK of a time connecting to Active Directory using VB in Visual Studio.NET 2003. Can anyone PLEASE help me? All I am trying to do is list the current members of our...
9
by: norvinl | last post by:
Hi, I'm serializing a class and using shared memory / deserialization to send it to other processes. I can serialize with one app and deserialize with another instance of the same app. But...
13
by: Rainer Queck | last post by:
Hi NG, It looks like I have a problem with the debugger. Running the current project every thing "looks" fine, but if I set a breakpoint at a certain position in my code it takes the debugger...
2
by: Jeff | last post by:
Hey ..NET 2.0 I'm developing an application which will perform some webservice calls and I believe having those calls in a separate thread may help the app run smoother No user are waiting...
12
by: sheldonlg | last post by:
Here is my situation. I am coding in an AJAX framework for an intranet application behind a vpn. Therefore, I can't give you a URL for the actual app. I made a sample app for viewing and am...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.