爲了說明我構建ConsoleApplication的問題。我在實例化方法時遇到了問題。
在我看來,我應該能夠實例化的方法是這樣的:
Vehicles.Car car = new Vehicles.Car();
但它不工作。對於我的生活,我看不出什麼是錯的。
Program.cs contains this:
namespace ConsoleApplicationTest
{
public class Program
{
static void Main(string[] args)
{
Vehicles.Car car = new Vehicles.Car();
}
}
}
Vehicles.cs包含此:
using System;
namespace ConsoleApplicationTest
{
public class Vehicles
{
public void Car()
{
Console.WriteLine("I am a car");
}
}
}
我忘了,包括錯誤。錯誤\t CS0426 \t「車輛」類型中不存在類型名稱'Car' –
澄清您實際想要實現的內容可能會有所幫助 - 實際上沒有稱爲「實例化方法」的共同概念。根據示例代碼,它可以嘗試使用委託,靜態方法,類構造函數,命名空間或完全不同的東西。 –
當我在學習的時候,我的詞彙量還沒有達到標準。我感謝你用我的術語幫助我。 –