Wednesday 19 August 2015

What is Static Class in C#.Net

      These was introduced in .Net Vs2.0 which can be defined only with static members. Initialization of the class is not possible because these were no instance members under the class.
                          Here Static was a special Modifier that can be applied on a class it's member. The Members on which Static is applied.  Don't require the object of the class for initialization or execution. 
                          A class is a collection of members where these members can be categorized into two types 
                                      1. Non-static or Instance members
                                       2. Static Members         
Sample Example :



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


namespace ConsoleApplication1
{
    static class strevrse


    {
        public static string stringreverse(string s)
        {
            char[] arr = s.ToCharArray();
            Array.Reverse(arr);
            return new string(arr);
        }
    
    }
    class stringreverse
    {
        static void Main(string[] args)
        {
            Console.WriteLine(strevrse.stringreverse("HELLO WORLD"));
            Console.WriteLine(strevrse.stringreverse("LOKESH"));
            Console.WriteLine(strevrse.stringreverse("GURAVAIAH"));


            Console.ReadLine();
    }
       
    }
}

No comments:

Post a Comment