Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
4.67/5 (3 votes)
See more:
I created code in the Form.cs and I added a class, (the whole thing acts as an MVC model, file executes the logic of the file, the other file illustrates it with WinForm changes. Problem is, as oppose to a console applications, I get mistakes that I don't understand why I get them

I get this mistake:

Error 2 Inconsistent accessibility: parameter type 'WindowsFormsApplication1.Pieces[*,*]' is less accessible than method 'WindowsFormsApplication1.ChessBoard.PrintPieces(WindowsFormsApplication1.Pieces[*,*])' D:\Documents and Settings\Dima\My Documents\Visual Studio 2008\Projects\ChessBoardGame\ChessBoardGame\ChessBoard.cs 1135 21 ChessBoardGame



I used one method in my Form class:

C#
public void PrintPieces(Pieces [,] pieces)
{
}


and in the class2 I call it like this
C# Syntax (Toggle Plain Text)

C#
public static void ExecuteAll(int rowStart,int columnStart,int rowEnd,int columnEnd) {
  Pieces[,] pieces = ChessBoard();
  ChessBoard chessB = new ChessBoard();
  chessB.PrintPieces(ChessBoard());
}


Why is it a mistake?

[EDIT]
Oooh, damn. I changed it now. Now the mistake is gone.
Does it mean that I can use the elements of both codes with no problem. I want the Form.cs to present the data on WinForm and the class that I have added to perform the code
Posted
Updated 12-Mar-11 14:29pm
v4

It is a mistake because your public method has as a parameter a class "Pieces" which is not itself publicly available.

It means that the method can never be called publicly, because it is impossible to supply the required parameter.

Change the definition of your method to match the availability of "Pieces" or make the "Pieces" class public as well.

By the way, I assume from the method parameters that the "Pieces" class represents a single chess piece with each instance. That makes a lot of sense, and is a good thing. However, the name implies that it holds more than one piece. Normally, an instance of a single object would have a singular name, rather than plural, allowing the plural to be used for a collection. I suggest that you change the name to "Piece" or possibly "ChessPiece".
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 12-Mar-11 18:10pm    
See my comment about public vs. internal in my comment to Robert's Answer.
--SA
You havea public method but the class Pieces is not. I assume its either private or internal. Make it public and everything should be ok.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 12-Mar-11 18:08pm    
Should be internal, not public if possible. Access should be minimal. Public is needed to be accessible from other assemblies or is the base class of overridden member was declared as public in base class.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900