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

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

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Followers

Total Pageviews

Powered by Blogger.

Blog Archive

- Copyright © 2013 DevStudent - Metrominimalist - Powered by Blogger - Designed by Johanes Djogan -