Nishant Mittal
How can I call non static method from Static Method??
By Nishant Mittal in C# on Jul 12 2016
  • p khot
    Mar, 2021 6

    we can call non static method from static method

    class xyz{

    1. public void Multi(){
    2. Console.WriteLine("Non Static Method");
    3. }

    }
    static class abc{

    1. static void Add(){
    2. xyz c=new xyz();
    3. c.Multi(); //calling non static method from static method
    4. Console.WriteLine("Static Method");
    5. }
    6. static void Main()
    7. {

    xyz a=new xyz();
    a.Multi();
    }}

    • 1
  • Nishant Mittal
    Jul, 2016 12

    private static void OnReadComplete(IAsyncResult result) {ClassName objClassName = new ClassName();objClassName.methodName(); }

    • 1
  • kajal rane
    Apr, 2019 7

    We can call non-static method from static method by creating instance of class belongs to method, eg) main() method is also static method and we can call non-static method from main() method .

    • 0
  • Bhanuprasad Mitturi
    Nov, 2018 20

    Even private methods can be called from static methods with class instance.

    • 0
  • Bhanuprasad Mitturi
    Nov, 2018 20

    yes. But we need to create object to call the method inside static method.

    • 0
  • Ayappan Alagesan
    Feb, 2017 10

    non static method must be a public method. non static method must be a public class. create a instance for that class and then we can access the method.

    • 0


Most Popular Job Functions


MOST LIKED QUESTIONS