- Category: .NET
Hi Benjamin Oluwasijii.
Static is a keyword in c#, which can be used for methods, variables and classes.
When ever we want to call a method with out creating object, then static comes in to picture.
Every program should have an entry point, so Main()(method) will be assigned with static keyword like below.
Public Static void Main()
You can create objects and you can perform any task only after entering in to program. So static method will be called with out object creation and making you enter in to program.
Void means that method is not going to return any value as result.
It is called as return type. Return types can be void, int, string so on..
Hope you understood.
Choose as best answer if you are satisfied.
Editor: DNS Forum.
- #761703When you say 'static' it means, it is a special [optional] keyword that indicates that this method can be called without creating an instance of this class.
And when you say 'Void' then it means void is the return type of this method, indicating that this method doesn't return anything. Methods must have a return type.
hope it helps
Editor, DotNetSpider MVM
Microsoft MVP 2014 [ASP.NET/IIS]
- #761708static means, you can call the function without creating object/instance of a class
You need an entry point for your program. So we are using static for the Main method
Direction is important than speed
- #761715Hello Benjamin Oluwasijii,
static means that the method is associated with the class, not a specific instance (object) of that class. This means that you can call a static method without creating an object of the class.
A static class is basically the same as a non-static class, but there is one difference: a static class cannot be instantiated.
Example code :
static class MyClass
public static int _value = 1;
static void Main()
Hope you understand.
DNS Gold Member
"Failure is the path of least persistence"
Thanks for acknowledging, hope you have understood the concept.
Select the category while posting the question according to you question type asp.net or c#.
If you learnt from defeat..
You haven't really lost..
Editor: DNS Forum.