We provide IT Services

Register Now Click On

Read More Tutorials Click On

Post Page Advertisement [Top]


Static variable does not create in non static class.

Static variable declare always global level and class level 
but we can't declare static variable on method level.

syntex:-

If you want to make the int B=15 static then out put is 11.

Static variable created by on time memory allocated but memory in will be value override.

As a before 11 then after override 12. 

Example of Static variable:-

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

namespace what_is_static_variable
{
   class Program
    {
        static int a = 10;
        public  void Show()
        {
             a++;
            Console.WriteLine(a);
        }
    }
    class Devesh
    {
       public static void Main(string[] args)
        {
            Program aa = new Program();
            aa.Show();
            Console.ReadKey();
        }
    }

}
Output:-

No comments:

Post a comment

| Designed by Rockprogrammer