inaccessible due to protection level HELP?!

B

BlueOysterCult

Hello
I can't get around the error "inaccessible due to its protection
level" - it points at a line that I am using .Sort() and
BinarySearch() - but the real problem lies in another part of the
code below(because the error says College.Persons_ThePersons....):

/// <summary>
/// Summary description for Persons.
/// </summary>
public class Persons
{
private ArrayList _ThePersons;

public Persons()
{
_ThePersons = new ArrayList();
}

public Persons(params Person [] arr)
{
// initialize the instance field _ThePersons
_ThePersons = new ArrayList();

// Add the person reference to the array list.
for (int i=0; i<arr.Length; i++)
{
_ThePersons.Add(arr);
}
}



// Indexer
public Person this [int index]
{
get
{
if (index >= 0 && index <= Count-1)
return (Person)_ThePersons[index];
else
return null;
}

set
{
if (index < 0)
{} //do nothing?
else if (index > 0 && index < Count-1)
_ThePersons[index] = value;
else
_ThePersons.Add(value);

}

}


//Properties
public int Count // Read-Only Property
{
get
{
return _ThePersons.Count;
}
}


public ArrayList ThePerson
{
get
{
return _ThePersons;
}
}


}
}



I believe some of its nested and that's why? Anyway, can someone see
something? I have been looing at it for a long time now and am not
seeing anything(really...)

Rob
 
J

Jon Skeet [C# MVP]

BlueOysterCult said:
I can't get around the error "inaccessible due to its protection
level" - it points at a line that I am using .Sort() and
BinarySearch() - but the real problem lies in another part of the
code below(because the error says College.Persons_ThePersons....):

<snip>

With a public Person class, it compiles fine on my box. Could you give
a short but complete program which *doesn't* compile?

See http://www.pobox.com/~skeet/csharp/complete.html for what I mean.
 
B

BlueOysterCult

Can I send you the cs file (its not that long.. if I print it out its
about 6 pages?
BTW I did put that code in its own file and didn't compile - what am I
doing wrong?
Rob
 
J

Jon Skeet [C# MVP]

BlueOysterCult said:
Can I send you the cs file (its not that long.. if I print it out its
about 6 pages?

I'm sure you can make it shorter if you try. Your code doesn't actually
need anything in the Person class, for instance - it just needs to know
that the class is there.
BTW I did put that code in its own file and didn't compile - what am I
doing wrong?

That depends on what the compiler error was, and how you tried to
compile it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top