- Back to Home »
- C#.NET »
- C#.NET Static Method
Posted by :
Sudhir Chekuri
Thursday, 31 December 2015
Static method is a method which can be called without any reference or object because memory for a static method is created in RAM when program is executed.
Static method is a method which is created using keyword "static".
Example
Addition of two numbers Program using static method and takes input arguments with return type
Program
Output
11
Static method is a method which is created using keyword "static".
Example
Addition of two numbers Program using static method and takes input arguments with return type
Program
using System;
namespace static_method
{
class Program
{
static void Main(string[] args)
{
long l = maths.add(4,
7);
Console.WriteLine(l);
Console.ReadKey();
}
class maths
{
public static long add(int i, int j)
{
return i + j;
}
}
}
}
Output
11