William Thompson

William Thompson

  • 1.5k
  • 130
  • 293.2k

How to make code run differently depending on the platform i

Apr 5 2019 12:04 PM
How to make code run differently depending on the platform it is running on?
 
I have a challenge for you.
 
I have an ASP.NET Web Application built in C# with Microsoft Visual Studio 2017. There is a line of code that we have had to include in order for it to run on a localhost when debugging by attaching it to a running process in a web browser.
 
Here is the issue. That line of code is not necessary when the process is running on the server.
 
I can remove that line when I submit the code in TFS. But it would be great if we could make the code somehow ignore that line depending on what platform it is running on.
 
How can you think this could be done?

Answers (1)