0

sorry for my bad english in advance.I'm making a game for a proyect in uni and got stuck in this part where i have to save all the player names per game in a collection. So i got these two classes

class Score
{
 ...
}
class ScoreList
{
  public List<Score> NamesList = new List<Score>();

  public ScoreList()
    {}
  public void addScorePlayers(string nom1, string nom2)
  {
    Score part = new Score(player1, player2);
    NamesList.Add(part);
  }
}

Then i create an object from the class in a form

public partial class FormCreateScoreList : Form
{
    public static ScoreList Names = new ScoreList();
    .....
    .....
}

Then in another form i add the name of the two players to the ScoreList

public partial class FormCreateScoreScreen : Form
{
  FormCreateScoreList.obj.addScorePlayers("Player1","Player2")
}

But when i debug, an error shows up saying

  "Inconsistent accessibility: parameter type 'FinalProject.ScoreList' is less accessible than method 'FinalProject.FormCreateScoreList.Names'"

Please help, i don't know how to use a method from an object i've created in form on another form

MattDavey
  • 8,897
  • 3
  • 31
  • 54

1 Answers1

5

Your FormCreateScoreList is public class yet your ScoreList is internal (default accessibility). Change your ScoreList to public (Score has to be changed as well to public).

gzaxx
  • 17,312
  • 2
  • 36
  • 54