我正在运行Visual Studio 2015和Windows 8.1。我正在努力使用控制台应用程序项目。
该解决方案在Visual Studio 2015中运行良好,但是当我尝试使用mcs-compiler编译它时,我得到两个错误(Kattis codetest使用mcs-kompiler)。找不到两个外部类。
我收到以下错误:
Program.cs(28,13):错误CS0246:类型或命名空间名称
Graph' could not be found. Are you missing an assembly reference? Program.cs(58,34): error CS0246: The type or namespace name
解算器' 无法找到。你错过了装配参考吗? 编译失败:2个错误,0个警告
代码很大,所以我只粘贴了它的一部分: Program类,其中main和对“Graph”和“Solver”的调用来自:
Call in Program.cs:
-----------------------------------------------------------------------------
// first call:
var edges = CliquesToEdges(cliques);
sudokuColour.Graph graph = new Graph(81, edges);
string line = "";
string storeLine = "";
string puzzle = "";
.
.
.
// second call:
for (int i = 0; i < store.Count(); i++)
{
puzzle = store.ElementAt(i);
sudokuColour.Solver solver = new Solver(graph, 9);
int node = -1;
foreach (char c in puzzle)
{
----------------------------------------------------------------------------
//Beginning of "Graph" class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using sudokuColour;
namespace sudokuColour
{
public class Graph
{
.
.
----------------------------------------------------------------------------
//Beginning of "Solver" class:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using sudokuColour;
namespace sudokuColour
{
public class Solver
{
private enum Result { Solved, Unsolved, Busted }
private readonly Graph graph;
----------------------------------------------------------------------------
错误是什么?
答案 0 :(得分:0)
sudokuColour.Solver solver = new Solver(graph, 9);
您必须在左侧对命名空间进行限定这一事实可能意味着您应该在右侧对命名空间进行限定:
sudokuColour.Solver solver = new sudokuColour.Solver(graph, 9);
或者,在代码文件的顶部添加using指令:
using sudokuColour;
或:
using Solver = sudokuColour.Solver;
同样适用于:
sudokuColour.Graph graph = new Graph(81, edges);
如果仍然不起作用:您可能错过了两个项目之间的项目引用(或包引用或程序集引用 - 但项目引用似乎最合适)。