我有一个名为ContactList的类,我做了一个实例,但它声称它不存在Class在App_code文件夹中,我有其他页面,我可以访问其他类,只有这个不能工作。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data;
using System.Web.UI.WebControls;
namespace CSC237_SportsPro_Holmbeck
{
public partial class DisplayContact : System.Web.UI.Page
{
private ContactList list;
protected void Page_Load(object sender, EventArgs e)
{
list = ContactList.GetList();
if (!IsPostBack)
this.DisplayList();
}
private void DisplayList()
{
ContactListBox.Items.Clear();
for (int i = 0; i < list.Count; i++)
ContactListBox.Items.Add(this.list[i].Display());
}
答案 0 :(得分:1)
正如建议所示,按ctrl
+ .
它会显示建议列表。选择适当的命名空间或在导入部分中包含该行。
using projectFolder.App_Code;
通过这一行代码,您可以为相应的类指定命名空间。
Namespace在C#程序中以两种方式大量使用。首先, .NET Framework类使用命名空间来组织其中的许多命名空间 类。其次,声明自己的命名空间可以帮助控制 大型编程项目中的类和方法名称的范围。
答案 1 :(得分:0)