【发布时间】:2025-11-21 22:30:01
【问题描述】:
我在 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 类放入的命名空间称为“Nodes”。
有什么建议吗?谢谢!
【问题讨论】:
标签: c# list oop compiler-errors nodes