public class CommonMethod

 {
        //静态实例调用非静态方法
        public static CommonMethod instance = new CommonMethod();

     public int GetID()
        {

      return 1;

   }

}

比如说调用 GetID() 方法,不用实例化CommonMethod类,只要执行CommonMethod.instance.GetID()即可。

相关文章:

  • 2021-11-15
  • 2022-12-23
  • 2022-01-29
  • 2022-12-23
  • 2022-01-26
  • 2022-02-09
  • 2021-09-15
  • 2021-12-17
猜你喜欢
  • 2021-08-16
  • 2021-10-31
  • 2022-01-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案