 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What are static member functions in C#?
Static functions can access only static variables. The static functions exist even before the object is created.
Set static functions as −
public static int getNum() {} The following is an example demonstrating the use of static functions −
Example
using System; namespace Demo {    class StaticVar {       public static int num;       public void count() {          num++;       }       public static int getNum() {          return num;       }    }    class StaticTester {       static void Main(string[] args) {          StaticVar s = new StaticVar();          s.count();          s.count();          s.count();          Console.WriteLine("Variable num: {0}", StaticVar.getNum());          Console.ReadKey();       }    } }  Output
Variable num: 3
Advertisements
 