Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static Constants in C#

People also ask

What is static variable in C with example?

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.

Is it static const or const static?

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.

What is static and dynamic variable in C?

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.