找不到类型或命名空间名称 'Bussen'(是否缺少 using 指令或程序集引用?)
The type or namespace name 'Bussen' could not be found (are you missing a using directive or an assembly reference?)
当我尝试编译我的源代码时,它给了我这个错误。当我 运行 程序形式 visual studio 时它工作。我目前正在为我和我的朋友们制作一个 windows 形式的纸牌游戏。这是我的主要 Program.cs 文件。
错误:
Program.cs(16,33): error CS0246: The type or namespace name 'Bussen'
could not be found (are you missing a using directive or an assembly
reference?)
代码:
using System;
using System.Windows.Forms;
using bussen;
namespace bussen
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Bussen());
}
}
}
另一个文件名为 forms1.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using bussen;
namespace bussen
{
public partial class Bussen : Form
{
public List<string> allCards = new List<string> { };
public List<string> CardsColour = new List<string> { };
public Bussen()
{
FormBorderStyle = FormBorderStyle.None;
WindowState = FormWindowState.Maximized;
InitializeComponent();
LoadCards();
}
private void SelectCard(object sender, EventArgs e)
{
Random rnd = new Random();
int RandomNumber = rnd.Next(0, allCards.Count);
try
{
if (CardsColour.IndexOf(allCards[RandomNumber]) < 26)
{
(sender as Button).ForeColor = System.Drawing.Color.Black;
}
else
{
(sender as Button).ForeColor = System.Drawing.Color.Red;
}
(sender as Button).Text = allCards[RandomNumber];
allCards.Remove(allCards[RandomNumber]);
}
catch
{
LoadCards();
}
}
public void LoadCards()
{
StreamReader streamreader = new StreamReader(@"cards.txt");
string line;
while ((line = streamreader.ReadLine()) != null)
{
allCards.Add(line);
if (CardsColour.Count < 52)
{
CardsColour.Add(line);
}
}
streamreader.Close();
}
private void Restart(object sender, EventArgs e)
{
Application.Restart();
}
}
}
我编译的时候应该提供了不止一个文件名
-它是 [scs "program.cs"]
-但应该是 [csc "program.cs" "Form1.cs" "Form1.Designer.cs"]
当我尝试编译我的源代码时,它给了我这个错误。当我 运行 程序形式 visual studio 时它工作。我目前正在为我和我的朋友们制作一个 windows 形式的纸牌游戏。这是我的主要 Program.cs 文件。
错误:
Program.cs(16,33): error CS0246: The type or namespace name 'Bussen' could not be found (are you missing a using directive or an assembly reference?)
代码:
using System;
using System.Windows.Forms;
using bussen;
namespace bussen
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Bussen());
}
}
}
另一个文件名为 forms1.cs
using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using bussen;
namespace bussen
{
public partial class Bussen : Form
{
public List<string> allCards = new List<string> { };
public List<string> CardsColour = new List<string> { };
public Bussen()
{
FormBorderStyle = FormBorderStyle.None;
WindowState = FormWindowState.Maximized;
InitializeComponent();
LoadCards();
}
private void SelectCard(object sender, EventArgs e)
{
Random rnd = new Random();
int RandomNumber = rnd.Next(0, allCards.Count);
try
{
if (CardsColour.IndexOf(allCards[RandomNumber]) < 26)
{
(sender as Button).ForeColor = System.Drawing.Color.Black;
}
else
{
(sender as Button).ForeColor = System.Drawing.Color.Red;
}
(sender as Button).Text = allCards[RandomNumber];
allCards.Remove(allCards[RandomNumber]);
}
catch
{
LoadCards();
}
}
public void LoadCards()
{
StreamReader streamreader = new StreamReader(@"cards.txt");
string line;
while ((line = streamreader.ReadLine()) != null)
{
allCards.Add(line);
if (CardsColour.Count < 52)
{
CardsColour.Add(line);
}
}
streamreader.Close();
}
private void Restart(object sender, EventArgs e)
{
Application.Restart();
}
}
}
我编译的时候应该提供了不止一个文件名 -它是 [scs "program.cs"] -但应该是 [csc "program.cs" "Form1.cs" "Form1.Designer.cs"]