How to define and use static class in C#

1 Answer

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    static class Calc
    {
        public static int n = 0;
    }
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Calc.n);
            Console.WriteLine(Calc.n++);
            Console.WriteLine(Calc.n++);
            Console.WriteLine(Calc.n++);
        }
    }
}


/*
run:
 
0
0
1
2

*/

 



answered Dec 31, 2016 by avibootz

Related questions

1 answer 210 views
1 answer 201 views
1 answer 204 views
1 answer 183 views
1 answer 187 views
1 answer 199 views
...