Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 10th, 2011, 08:55 PM
Authorized User
Points: 84, Level: 1
Points: 84, Level: 1 Points: 84, Level: 1 Points: 84, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Default Constants & Common Functions: Where do they go?

I have several set values for my calculator that I need to be able to use throughout my website along with a few Functions that I would like to do the same. I would like to be able to place these Constants & Functions in one place where I can update them once and have them apply to all my calculations (I have 3 different sets of similar calculations that are performed in 3 subfolders). Is this possible?

Last edited by DragonLEG; June 10th, 2011 at 08:58 PM.. Reason: Forgot a part
 
Old June 11th, 2011, 02:02 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

If you have a Web Site Project, you can define them in a class inside the App_Code folder. For a Web Application Project, you can place a code file pretty much anywhere (except in App_Code). Then you can define the values in a class like this:

Code:
 
public class Constants
{
  public const double Whatever = 4.1;
}
You can then access the value using Constants.Whatever. You may also need to add a using statement for the namespace of the Constants class.

Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
The Following User Says Thank You to Imar For This Useful Post:
DragonLEG (June 13th, 2011)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing Constants within a session mat41 Classic ASP Basics 2 August 27th, 2009 12:11 AM
declaring constants and pointer constants proslambano BOOK: Ivor Horton's Beginning Visual C++ 2005 3 March 6th, 2007 03:32 PM
Constants in XSL austinf XSLT 2 August 29th, 2006 06:04 AM
Global/Public Constants elansolutionsltd Access 6 May 13th, 2005 12:22 PM
DriveType constants fordrs3 Beginning VB 6 1 June 22nd, 2003 08:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.