1) A static int variable remains in memory while the program is running. A normal or auto variable is destroyed when a function call where the variable was declared is over. For example, we can use static int to count a number of times a function is called, but an auto variable can't be used for this purpose.
They mean exactly the same thing. You're free to choose whichever you think is easier to read. In C, you should place static at the start, but it's not yet required.
In the static memory allocation, variables get allocated permanently, till the program executes or function call finishes. In the Dynamic memory allocation, variables get allocated only if your program unit gets active.
public static class Constants
{
public const string FrameworkName = "Rapido Framework";
}
A const is already static as it cannot change between instances.
You don't need to declare it as static - public const string is enough.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With