gpt4 book ai didi

c# - 代码找不到类

转载 作者:行者123 更新时间:2023-12-04 17:02:40 26 4
gpt4 key购买 nike

我有一个名为 ContactList 的类,我创建了一个实例,但它声称它不存在,该类在 App_code 文件夹中,我还有其他页面可以从中访问其他类,只有这个页面不起作用。

Image of error

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());
}

最佳答案

正如建议所说,按 ctrl + .它将显示建议列表。选择适当的命名空间或在导入部分包含该行。
using projectFolder.App_Code;
通过这一行代码,您可以为相应的类指定命名空间。

Namespace are heavily used within C# programs in two ways. Firstly, the .NET Framework classes use namespaces to organize its many classes. Secondly, declaring your own namespaces can help control the scope of class and method names in larger programming projects.

关于c# - 代码找不到类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35977779/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com