Aaron Bratcher
Aaron Bratcher

Reputation: 6471

How do I define a set of constants that can vary by configuration?

I would like to setup a set of constants that need to vary depending on whether I'm building for dev, qa, or production. How do I do that with Xamarin?

Upvotes: 2

Views: 754

Answers (1)

SharpMobileCode
SharpMobileCode

Reputation: 938

One idea is to have separate build configurations for each of your environments. Then user Compile Directives to determine which constant to use. So something like:

#if __DEV
  const string ConnectionString = "Dev Connection String";
#end if

Update: Alternatively, what I do on one of my other apps is I present a screen to the user to ask them to select an environment: "DEV", "QA", "STAGE", or "PROD". And depending on what their choice is, I use the web service address for the respective environment.

Upvotes: 2

Related Questions