Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 2005 > C# 2005
|
C# 2005 For discussion of Visual C# 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 28th, 2010, 07:44 PM
Friend of Wrox
 
Join Date: Jun 2005
Posts: 101
Thanks: 0
Thanked 1 Time in 1 Post
Default How do I get around Inconsistant accessibilty error in C # ?

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.
 
Old April 29th, 2010, 02:57 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

It should be fairly obvious in your example that class B is private, so only the class A can see it - yet class A tries to expose the method F which uses this private class which no-one else would be able to call.

Obviously making B public fixes the problem - is there some reason why this doesn't work in your code?

Otherwise I think you are going to have to give us an example that is closer to your real code.
__________________
/- Sam Judson : Wrox Technical Editor -/

Think before you post: What have you tried?
 
Old April 29th, 2010, 03:55 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

To put it another way, method F is unusable outside of A as it requires an instance of B which cannot be created externally. If F were made private or B were made public then you'd be fine.
__________________
Joe
http://joe.fawcett.name/





Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting error XML Parsing Error: junk after document element anarleti XSLT 10 March 17th, 2010 08:43 AM
Remote Connection Error: Named Pipes Provider error hbansal ASP.NET 2.0 Basics 5 April 12th, 2009 09:51 AM
Error: Microsoft VBScript compilation error '800a0409' webXtreme Classic ASP Basics 4 February 4th, 2009 03:58 AM
Insert Query Error & Run-Time Error 3022 DavidWE Access 1 July 31st, 2008 11:17 AM
Ch 4: Parse error: syntax error, unexpected T_SL hanizar77 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 0 June 23rd, 2008 09:17 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.