title: #if PreProcessor in C#
body: <p>I am new to C#/Asp.net World, Recently I came across the #if DEBUG PreProcessor but even after looking at the posts on Stack Over flow and MSDN Website and other blogs as well I am not able To make it Work.</p>
  
  <p>I am Making a small Website.
  I am implementing a DataLayer by Adding A new Project To The Solution.
  In The Datalayer I am checking the Parameters passed to the Stored Procedure.</p>
  
  <p>So The Aim is to print the Parameters Passed when The Application is running in Debug Mode and When The application is Running in Release Mode it Should not Show the Parameters.</p>
  
  <p>any Help Shall Be Appreciated.</p>
  
  <p>Thanks</p>
  
  <pre><code>#define DEBUG
  
  using System;
  using System.Data;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using TestWebsite.DataLayer.BussinessObjects;
  using Microsoft.Practices.EnterpriseLibrary.Data;
  using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
  using System.Data.Common;
  
  namespace TestWebsite.DataLayer  
  {  
      public class StatesManager  
      {   
          public ICollection&lt;States&gt; getAll(States statesObj)  
          {  
              List&lt;object&gt; parameters = new List&lt;object&gt;();  
              List&lt;States&gt; scol = new List&lt;States&gt;();  
              try  
              {  
                  parameters.Add(statesObj.State);
                  parameters.Add(statesObj.Abbreviation);
                  parameters.Add(statesObj.StartRowIndex);
                  parameters.Add(statesObj.MaximumRowsCount);
                  parameters.Add(statesObj.SortExpression);
                  parameters.Add(statesObj.SortDirection);
  
  #if DEBUG
                  System.Web.HttpContext.Current.Response.Write("State =" + statesObj.State + ",&lt;br/&gt;");
                  System.Web.HttpContext.Current.Response.Write("Abbreviation =" + statesObj.Abbreviation + ",&lt;br/&gt;");
                  System.Web.HttpContext.Current.Response.Write("StartRowIndex =" + statesObj.StartRowIndex.ToString() + ",&lt;br/&gt;");
                  System.Web.HttpContext.Current.Response.Write("MaximumRowsCount =" + statesObj.MaximumRowsCount.ToString() + ",&lt;br/&gt;");
                  System.Web.HttpContext.Current.Response.Write("SortExpression =" + statesObj.SortExpression + ",&lt;br/&gt;");
                  System.Web.HttpContext.Current.Response.Write("SortDirection =" + statesObj.SortDirection.ToString() + "&lt;br/&gt;");
  #endif
  
                  object[] paramArray = parameters.ToArray();
  
                  SqlDatabase db = new SqlDatabase(ConnectionManager.ConnectionString);
                  DbCommand dbCommand = db.GetStoredProcCommand("GetAllStates", paramArray);
                  IDataReader reader = db.ExecuteReader(dbCommand);
  
                  while (reader.Read())
                  {
                      States sreader = new States();
                      sreader.State = (string)reader[reader.GetOrdinal("State")];
                      sreader.Abbreviation = (string)reader[reader.GetOrdinal("Abbreviation")];
                      sreader.IsActive = (bool)reader[reader.GetOrdinal("IsActive")];
                      sreader.RowNumber = (long)reader[reader.GetOrdinal("RowNo")];
                      sreader.StateID = (int)reader[reader.GetOrdinal("StateID")];
  
                      scol.Add(sreader);
                      sreader = null;
                  }
                  reader.Dispose();
              }
              catch (Exception ex)
              {
                  throw ex;
              }
              finally { parameters = null; }
              return scol;
          }  
      }  
  } 
  </code></pre>