Hi,
In non OO world, mainly in C it is used as #defined.
But in OO world it is not best practice to use variable as publicly visible member, for many reason.
However, if you want to make a variable public then you may want to use them as static constant.
public static class GlobalVariables
{
public static const int InputNumber = 25;
}
public class Class1
{
var i = GlobalVariables.InputNumber;
}
public class Class2
{
var i = GlobalVariables.InputNumber;
}
Unless the InputNumber is never going to change, I wouldn't use it as constant.
It would be far better if you derive the variable as a property from a derived class, either as Abstract or Interface.
Regadrs
Jegan