命名空间无法正常工作

时间:2014-03-04 03:32:44

标签: c#

我的命名空间出现“无法找到类型或命名空间名称的错误(您是否缺少using指令或程序集引用?)”我收到错误“并且不知道为什么......我一直在尝试现在想出几个小时...顺便说一下我是c#

的新手
using System;
using System.Data; 
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using portfolioNamespace;  

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

    Portfolio myPortfolio;

    protected void Page_Load(object sender, EventArgs e){
        //declare
        myPortfolio = new Portfolio();
        populate();
    } 

    private void populate(){
        //populate everything
        populateMenu();
        populateHome();
        populateSamples();
        populateAbout();
    }

    private void populateMenu(){
        //populate the menu
        String[] menu;
        menu = myPortfolio.getMyMenu();

        repLinks.DataSource = menu;
        repLinks.DataBind();
        //populates a hidden text box so i can get an array in javascript 
        for (int i = 0; i<=menu.Length - 1; i++){
            dummy.Value = dummy.Value & menu(i) & "-";
        }
    }

    private void populateHome(){
        //populate home 
        homeRepeater.DataSource = myPortfolio.getHomeInfo;
        homeRepeater.DataBind();
    }

    private void populateSamples(){
        //populate samples
        samplesRepeater.DataSource = myPortfolio.getSamplesInfo;
        samplesRepeater.DataBind();
    }

    private void populateAbout(){
        //populate about
        aboutRepeater.DataSource = myPortfolio.getAboutInfo;
        aboutRepeater.DataBind();
    }

}

3 个答案:

答案 0 :(得分:0)

Solution Explorer中右键单击References,点击Add Reference > Browse,然后找到包含dll的{​​{1}}文件,并将其添加到参考文献中。< / p>

有关详细信息,请参阅文档:How to: Add or Remove References By Using the Add Reference Dialog Box

答案 1 :(得分:0)

您可能尚未创建portfolioNamespace。

您可以将代码包装在

namespace portfolioNamespace
{
 //your code here
}

仔细阅读这些参考文献,namespace (C# Reference)Namespaces (C# Programming Guide)

答案 2 :(得分:0)

目前尚不清楚哪个文件出错。

无论类名是什么,都将错误放在光标上并按下CTRL + DOT(。),它会建议你添加正确的名称空间