0

Here's what I am doing right now:

public static class CONST
{
    public static bool CarTmr = false;

Is this another way to do this that is more commonly used?

Alan2
  • 23,493
  • 79
  • 256
  • 450
  • `public static readonly bool ...` or `public const bool ...` More info: https://stackoverflow.com/questions/755685/static-readonly-vs-const – Andy Nov 14 '20 at 07:11

1 Answers1

1

I'd go with the Microsoft recomended way

static class Constants
{
    public const double Pi = 3.14159;
    public const int SpeedOfLight = 300000; // km per sec.
}

// Accessible like
double area = Constants.Pi * (radius * radius);

So in your case:

public static class CONST
{
    public const bool CarTmr = false;
}

Depending on the situation, you could also setup a class that reads from the configuration, if those constants relate to runtime and might be changed in the future.

There is no Xamarin specific, better way to achieve it.

Athanasios Kataras
  • 25,191
  • 4
  • 32
  • 61