How to use static class in C#

2 Answers

0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    public static class SClass
    {
        public static void Method()
        {
            Console.WriteLine("Method() from SClass");
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            SClass.Method();
        }
    }
}


/*
run:

Method() from SClass

*/

 



answered Jul 31, 2018 by avibootz
0 votes
using System;

namespace ConsoleApplication_C_Sharp
{
    public static class SClass
    {
        public static int si = 10;
    }
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(++SClass.si);
        }
    }
}


/*
run:
 
11
 
*/

 



answered Aug 6, 2018 by avibootz

Related questions

2 answers 206 views
206 views asked Aug 25, 2018 by avibootz
1 answer 215 views
1 answer 206 views
1 answer 212 views
1 answer 187 views
1 answer 191 views
1 answer 176 views
176 views asked Dec 31, 2016 by avibootz
...