gpt4 book ai didi

c# - 自建的Node \List 类到系统节点和列表之间的C#模糊引用

转载 作者:行者123 更新时间:2023-12-02 11:00:55 24 4
gpt4 key购买 nike

我已经在C#中构建了自己的Node \ List类,并且尝试在新项目中使用它们,但是vs似乎给了我无数的错误,我不知道该如何解决。

代码:

    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Students;
using Nodes;






namespace schoolNodes
{
class Program
{

public static Student Best(List<Student> x)
{
Node<Student> p = x.GetFirst();
Student tal, talmax = null;
float mem, max = 0;

while (p != null)
{
tal = p.GetValue();
mem = tal.Avg();
if (mem > max)
{
max = mem;
talmax = tal;
}
p = p.GetNext();
}
return talmax;
}

public static int NumTeacherOfClass(string s, List<Teacher> l)
{
Node<Teacher> p = l.GetFirst();
int n = 0;

while (p != null)
{
if (p.GetValue().CheckClass(s))
n++;
p = p.GetNext();
}

return n;
}

无论哪里有List <...>,它都会给我一个错误。
我将Node \ List类放入其中的 namespace 称为“节点”。

有什么建议?谢谢!

最佳答案

您正在将System.Collections.GenericNodes一起使用,其中包含List定义。这导致编译器错误。尝试对 namespace 使用全名,例如Nodes.List<Student>而不是List<Student>

关于c# - 自建的Node <T>\List <T>类到系统节点和列表之间的C#模糊引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41033659/

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