0

why 'static' appears in C#?

it seems difficult to understand why 'static' appears in C#?

2nd Oct 2017, 3:38 PM
William
5 Answers
+ 14
Same reason why static modifier exists for other languages. Static declares that the member belongs to the type/class itself rather than the object/instance of the class. In other words, a static member can be called directly using the class name without using the class object. http://csharp.net-tutorials.com/classes/static-members/
2nd Oct 2017, 3:47 PM
Hatsy Rei
Hatsy Rei - avatar
+ 3
Static appears in c# in static classes and static members...this is because static class can be used as a convenient container for sets of methods that just operate on input parameters and do not have to get or set any internal instance fields. The advantage of using static class is that compiler can check to make sure that no instance members are accidently added.the compiler will guarantee that instance of this class cannot be created.also static class cannot be inherited. Similarly static members always will be accessed by class name Mr instance name...
2nd Oct 2017, 4:03 PM
Prabhat Thakur
Prabhat Thakur - avatar
0
If no other status or type besides 'static', what's its meaning to emphasis it alone? I think the course should give bigger picture of this.
3rd Oct 2017, 2:06 AM
William
0
It should be named as 'predefined' or 'inner-declared', other than 'static'. The later always induces me thinking of where's 'dynamic'.
3rd Oct 2017, 2:31 AM
William
- 2
is there 'dynamic'?
2nd Oct 2017, 3:58 PM
William