c# call a method from another class code example
Example 1: c# how to call methods from another class
public class AllMethods
{
public static void Method2()
{
}
}
class Caller
{
public static void Main(string[] args)
{
AllMethods.Method2();
}
}
Example 2: how to call a method from a class C#
classname.methodname();
Example 3: c# how to call methods from another class
namespace Some.Namespace
{
public class AllMethods
{
public static void Method2()
{
}
}
}
using static Some.Namespace.AllMethods;
namespace Other.Namespace
{
class Caller
{
public static void Main(string[] args)
{
Method2();
}
}
}