void是指没返回值static是指函数是类(class)函数,不是实例(instance)函数,意即它跟该类的实例的实例成员(instance members)无关

解决方案 »

  1.   

    using System;class TestClass
    {
      String s1 = "Hello, CSDN!";//实例成员
      static String s2 = "I am coming!"; //静态类成员
      public void Test1() //实例函数
      {
    Console.WriteLine(s1);///可以调用实例成员 Console.WriteLine(s2);//可以调用静态类成员
      }  public static void Test2() //静态类函数
      {
    //Console.WriteLine(s1);//不能调用实例成员
    Console.WriteLine(s2);//可以调用静态类成员
      }
    }class TestDriver
    {
      public static void Main()
      {
    TestClass tc = new TestClass();
    tc.Test1();//需要产生实例才能调用实例函数 TestClass.Test2();//用类名直接调用静态类函数
      }
    }
      

  2.   

    using System;class TestClass
    {
      String s1 = "Hello, CSDN!";//实例成员
      static String s2 = "I am coming!"; //静态类成员
      public void Test1() //实例函数
      {
    Console.WriteLine(s1);///可以调用实例成员
    Console.WriteLine(s2);//可以调用静态类成员
      }  public static void Test2() //静态类函数
      {
    //Console.WriteLine(s1);//不能调用实例成员
    Console.WriteLine(s2);//可以调用静态类成员
      }
    }class TestDriver
    {
      public static void Main()
      {
    TestClass tc = new TestClass();
    tc.Test1();//需要产生实例才能调用实例函数 TestClass.Test2();//用类名直接调用静态类函数
      }
    }