0

When do I use the static method in C#

I am fairly new to c# and I was wondering what was the static keyword used for. I know that you declare a function with static void functionName() {}. I know that void means that it returns nothing when it is called and just executes the code. So what is the static keyword and when do you use it in practice?

10th May 2019, 2:31 AM
Sticks Studios
Sticks Studios - avatar
3 ответов
0
NEVER! Except for Extension Methods.
10th May 2019, 7:31 AM
Daniel Adam
Daniel Adam - avatar
0
Static is when the property or the method is not bound to a object. You just need a method or set a property but is more general. The Math class is a good example. You do not want to create a Math object, you just want to use some methods that do something for you and are grouped in a class. That is what you call static. https://www.geeksforgeeks.org/c-sharp-math-class/ https://code.sololearn.com/cre3xJMpvFCY
10th May 2019, 7:46 PM
sneeze
sneeze - avatar