Can call a non-static method through an object reference from within a static method : Static : Class Interface C# Source Code


Custom Search

C# Source Code » Class Interface » Static »

 

Can call a non-static method through an object reference from within a static method








    

/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
using System;

public class MyClass { 
  // non-static method. 
  void nonStaticMeth() { 
     Console.WriteLine("Inside nonStaticMeth()."); 
  } 
 
  /* Can call a non-static method through an 
     object reference from within a static method. */ 
  public static void staticMeth(MyClass ob) { 
    ob.nonStaticMeth(); // this is OK 
  } 
}


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Class Interface
» Static