Static functions

Static functions are the functions which are not bounded by the space of any class. They are called directly without making an object from which class they belong. Following example demonstrate the things.

Example

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace ConsoleApplication1
{
    class Program
    {
        static void function1()
        {
            Console.WriteLine("static methods")
        }

        void function2()
        {
            Console.WriteLine("non static method");
        }

        static void Main(string[] args)
        {
            function1(); // static methods called directly
            function2(); // will give error, because not static
            // in order to use function2, we need an object
            Program pr = new Program(); // object created
            pr.function2(); // function2 called
            Console.Read();
        }
    }
}