zoukankan      html  css  js  c++  java
  • 对象引用对于非静态的字段、方法、属性Program.Print()是必需的

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

    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> 实例化一个对象

  • 相关阅读:
    20201107
    20201024
    20201020
    20200331
    20200330
    20200320
    20200319
    20200310
    20200221
    20190926
  • 原文地址:https://www.cnblogs.com/zhangyuhao/p/10121447.html
Copyright © 2011-2022 走看看