PDA

View Full Version : How do I get around Inconsistant accessibilty error in C # ?


complete
04-29-2010, 12:45 AM
How do I get around Inconsistant accessibilty error in C # ?

I need to pass a pointer to a node in a linked list to a method.
When I do, I get a "Compiler Error CS0051"

Example
The following sample generates CS0051:

Copy Code
// CS0051.cs
public class A
{
// Try making B public since F is public
// B is implicitly private here
class B
{
}

public static void F(B b) // CS0051
{
}

public static void Main()
{
}
}


That is a simple example. The actual program is a bit more complicated. I am actually using a node in a linked list to pass to the method
LinkedListNode<LevelNode> node

The method uses recursion because the node is mart of a huge linked list structure of linked lists that outputs an xml file.
Either I have to find a way to use recursion without using methods or I need to find a way to pass pointers nodes or actual nodes.

oracleguy
04-29-2010, 05:26 PM
You can't make B private and then have a public method on A that uses B as a parameter. How would anyone from the outside use the function if they can't create an instance of B since it is private to A? That is why if you make the F function public, B needs to be public.