Just Code‎ > ‎

C# - Get config from non default config section

posted Feb 14, 2010, 3:49 AM by Peter Henell

public static int NumOldDaysAssignmentsToShow
        {
            get
            {
                int num = 0;
                NameValueCollection nvc = ConfigurationManager.GetSection("MyConfigSection") as NameValueCollection;
                int.TryParse(nvc["NumOldDaysAssignmentsToShow"], out num);

                if(num != 0)
                    return -1 * num;
                // Default value jic
                return -90;
             }
        }
Comments