Answers for "function call c#"

C#
2

c# call method

// Call method using 'static':
class ClassA
{
	static void Main(string[] args)
    {
    	ClassB.Method1();
    }
}

class ClassB
{
	public static void Method1()
    {
    	// do something...
    }
}

// Call method using an object:
class ClassC
{
	static void Main(string[] args)
    {
    	ClassD loadMethod = new ClassD();
      	loadMethod.Method1();
    }
}
  
class ClassD
{
	public void Method1()
    {
    	// do something...
    }
}
Posted by: Guest on July-23-2021

C# Answers by Framework

Browse Popular Code Answers by Language