无法从另一个类调用方法

Han*_*aka -3 c#

我试着打电话myCar.FormatMe(),但没有表现出来.我不知道为什么.有什么建议?

using System;
namespace SimpleClasses
{
    class Program
    {
        static void Main(string[] args)
        {
            Car myCar = new Car();
            myCar.Make = "BMW";      
            myCar.FormatMe();
            Console.ReadLine();
        }
    }

    class Car
    {
        public string Make { get; set; }
        public string FormatMe()
        {
            return string.Format("Make: {0}", this.Make);
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

非常感谢.

tec*_*der 11

您的代码中没有输出

class Program
{
    static void Main(string[] args)
    {
        Car myCar = new Car();
        myCar.Make = "BMW";      
        Console.WriteLine(myCar.FormatMe());
    }
}

class Car
{
    public string Make { get; set; }
    public string FormatMe()
    {
        return string.Format("Make: {0}", this.Make);
    }

}
Run Code Online (Sandbox Code Playgroud)