c# - 找不到类型或命名空间名称 'Bussen'(您是否缺少 using 指令或程序集引用?)

标签 c# forms types namespaces csc

当我尝试编译我的源代码时,它给了我这个错误。当我从 Visual Studio 运行程序时,它可以工作。我目前正在为我和我的 friend 创建一个 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"]

关于c# - 找不到类型或命名空间名称 'Bussen'(您是否缺少 using 指令或程序集引用?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61124052/

相关文章:

c# - (Action<T>).Name 不返回预期值

c# - 这把锁有什么问题?

python - Django 表单和初始值

php - 使用 ajax 和 jquery 从数据库动态添加预填充表单

php - Blueimp jQuery 文件上传,传递额外的表单数据

types - IEEE-754 float 是如何工作的

c# - 从 WSDL 文件在 Visual Studio 中创建 Web 服务代理

c# - decimal.parse ("value") 看起来很奇怪

c# - 为什么 "int + string"在静态类型的 C# 中可能,但在动态类型的 Python 中却不行?

haskell - 如何在 haskell 中创建几种相关的数据类型?