Answers for "how to call a method in 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
0

function in c#

//function example
using System;
					
public class Program
{
	static void function(){
		Console.WriteLine("I am a function!");
	}
	public static void Main()
	{
		function();
	}
}
Posted by: Guest on March-30-2020

Code answers related to "how to call a method in c#"

C# Answers by Framework

Browse Popular Code Answers by Language