0
What is the dfference between static methods and nonstatic methods?
In c# lessons sometime a method is declared "static int" and sometime is just "int". So my question is: what is the difference between "static <type>" and just "<type>"
4 ответов
+ 4
static means the value going to be shared by all instances instead of individual value for each instance.
You can always refer to MSDN for good explanation and example:-
https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/static
+ 3
You can always initialize an instance of the class provided it's not static. Think of it like a blueprint.
Let's say we have a class ElectricPokemon with attributes Name and a static attribute Type.
In this case, every new ElectricPokemon (instance) created (i.e. Pikachu, Jolteon, Zapdos & etc.) will have different *Name* but sharing the same *Type*.
Crystal clear or clear as mud? 😉
0
Can you tell me like to an 6 year child, what "shared by all instances" means. Because englosh isn't my main laguage and I did'n understant that l
part
0
Yes. Thanks.