找不到类型或命名空间

时间:2014-04-06 17:02:59

标签: html asp.net sql database

你好,我正在做一个任务,我正在使用的程序是visual studio 2012实验室我在.cs文件后面的代码中出错了它给我的错误是第20行和编译错误消息说< / p>

The type or namespace name 'Player' could not be found (are you missing a using directive or an assembly reference?). 

请帮帮我

Line 18:     protected void addPlayer(String name, int jersey, String team){
Line 19: 
Line 20:         Player player = new Player(name, jersey);
Line 21: 
Line 22:         if ( String.Equals(team, "team 1", StringComparison.OrdinalIgnoreCase))

我的整个代码是

public partial class _default : System.Web.UI.Page
{

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void addPlayer(String name, int jersey, String team){

        player = new player(name, jersey);

        if ( String.Equals(team, "team 1", StringComparison.OrdinalIgnoreCase))
            listTeam1.Items.Add(player.getName() + "-" + player.getJersey());
        else if (String.Equals(team, "team 2", StringComparison.OrdinalIgnoreCase))
            listTeam2.Items.Add(player.getName() + "-" + player.getJersey());
    }

    protected int numPlayers(String team)
    {
        if (String.Equals(team, "team 1", StringComparison.OrdinalIgnoreCase))
            return listTeam1.Items.Count;
        else if (String.Equals(team, "team 2", StringComparison.OrdinalIgnoreCase))
            return listTeam2.Items.Count;
        else
            return 0;
    }

    protected void buttonLeft_Click(object sender, EventArgs e)
    {
        String addedItem = listTeam2.SelectedItem.Text;

        listTeam2.Items.RemoveAt(listTeam2.SelectedIndex);
        listTeam1.Items.Add(addedItem);


    }

    protected void buttonRight_Click(object sender, EventArgs e)
    {
        String addedItem = listTeam1.SelectedItem.Text;

        listTeam1.Items.RemoveAt(listTeam1.SelectedIndex);
        listTeam2.Items.Add(addedItem);

    }

    protected void buttonAdd_Click(object sender, EventArgs e)
    {
        addPlayer(tbName.Text, int.Parse(tbJersey.Text), radioTeam.SelectedItem.Text);

        tbJersey.Text = "";
        tbName.Text = "";
    }
}

1 个答案:

答案 0 :(得分:0)

当您收到此错误时,它就意味着它所说的内容。它不知道是什么播放器,因此它可能在另一个命名空间中。您需要一个导入命名空间的using指令。如果Player在另一个程序集中,则需要添加对该程序集的引用。