在学习重载是以下代码报错:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 值类型1
{
    class Program
    {
        static void Main(string[] args)
        {
            Print();
        }
        public void Print()
        {
            Console.Write("Hello");
        }
        public void Print(string name)
        {
            Console.Write("Hello"+ name);
        }
    }
}

  解决方法  1>将方法定义为static  2> 实例化一个对象

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-12
  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
  • 2021-09-08
猜你喜欢
  • 2021-11-08
  • 2021-06-08
  • 2022-12-23
  • 2022-12-23
  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案