---
title: "Creating Static Methods in C#"  
description: "Introduction:Static Methods are methods that can be accessed without creating instances of the class. Static methods supply the easy way to call the m"  
author: "Shankar M"  
published: 2013-02-09  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/440/creating-static-methods-in-c-sharp  
category: "c#"  
tags: ["c#"]  
reading_time: 2 minutes  

---

# Creating Static Methods in C#

##### Introduction:

[Static Methods](https://www.mindstick.com/forum/161339/static-methods-in-python) are methods that can be accessed without creating [instances](https://answers.mindstick.com/qa/92508/how-can-you-hide-the-sql-server-instances) of the class. Static methods supply the easy way to call the methods based on the Flexibility in our code.

##### Static Methods does not require Object:

Static Methods does not require creating instances of the class object. So we don't instantiate

MyClass obj= new MyClass ();

##### Creating a static Method:

Creating a [static method](https://www.mindstick.com/forum/216/can-i-override-a-static-method) is as simple as creating a normal [method in C#](https://www.mindstick.com/forum/33924/can-this-be-used-within-a-static-method-in-c-sharp). The only different from a normal method is the word static.

In this example, I have created a new class named StatMethod that defines a new static Method Add.

```
public static int Add(int val1, int val2){    return val1 + val2;}
```

\

The above code defines a static method Add which accpets [integer](https://answers.mindstick.com/qa/113667/write-code-for-roman-to-integer) paramters and returns the sum of the Input given.

##### Calling a static Method:

Since static Methods do not require creating [instance](https://www.mindstick.com/forum/1739/object-reference-is-not-set-to-an-instance-of-an-object-error-in-my-code) of the Class, the static method can be called using the Syntax :

##### classname.methodname ( )

##### To call our Add Method in the Class StatMethod,

##### StatMethod.Add(1,2)

As this is a static Method,we don't require creating a new object of the class StatMethod and we can call the Method Add straight way.

Static methods provides a way to quick [access](https://www.mindstick.com/articles/12994/how-foreigners-can-access-blocked-websites-in-china) to the method.

\
Points to Remember:

A static method does not require creating instances.

Regarding Performance, Static methods are normally [faster](https://yourviews.mindstick.com/story/1515/5-ways-to-get-in-shape-faster) to invoke on

the call stack than instance method

Thanks you

---

Original Source: https://www.mindstick.com/blog/440/creating-static-methods-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
