473,395 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Implementing .h files/#defines in web-based app using c#

I've been assigned to support a web-based app (code behind page model)
written in C# using Visual Studio 2005. I am completely new to web apps, C#,
and Visual Studio 2005. This app was developed using hardcoded strings and
numeric values that should have been defined in one location (like a #define
in a .h file in c++). I have searched for a good, clear, useful explanation
on how to do this where the web page code (aspx) and the C# code can both use
the constant definition but have not found one. Can anyone provide a clear,
useful explanation/example on this or a link the explains this that will go
beyond ".h files are not used in C#"? I would greatly appreciate the help.
--
Dave Askren
Lebanon, NH
Nov 2 '06 #1
1 1097
Create a struct to hold your constants. Something like this:

namespace YourNameSpace
{
public struct Constant
{
public static readonly int MIN_VALUE = -1;
public static readonly int MAX_VALUE = 16000;
public static readonly string SOK = "OK";
public static readonly string SCancel = "Cancel";
// etc
}
}

Replace all hard-coded values with the Constant values

--
Regards, Peter
Nov 3 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Maurice | last post by:
Hi, We are implementing some wrappers in C++ according to the Adapter Pattern. The classes and their methods in the Adaptee classes (open-source library) have already the interface that we like,...
11
by: Marc Ferry | last post by:
I already posted this mail in comp.sys.hp and comp.sys.hp.hpux but had no response. As this problem might be present on other OSes than HP-UX 10.20, I crosspost it here, in the hope of getting an...
12
by: David Ross | last post by:
I want to write and install a personalized "404 Error" page. How do I do that? I have over 200 HTML files on my Web site. I'm concerned that, if I change or move a file, I might not detect all...
0
by: Neil Moss | last post by:
Hi all Can anyone tell me if .resx files ignore the BuildAction property? I have two resx files in my project, and I wish to choose which one is actually compiled into my executable. So, I set...
1
by: alanrn | last post by:
I've implemented a number of strongly-typed collections that inherit from CollectionBase and recently noticed something that I don't fully understand. CollectionBase defines method RemoveAt(). ...
3
by: thechaosengine | last post by:
Hi all, Can anyone tell me if it is advisable (or even possible) to define a namespace across 2 or more assemblies? For example, consider the namespace SampleApplication.Data.Providers ...
8
by: hex | last post by:
Hi I make a class "MyClass" and this clas implements the Interface ICloneable. I want when I instance an object from MyClass and I call obj.Clone() it returns an object of MyClass type. for...
11
by: David Thielen | last post by:
Hi; I am writing a class that implements IDbConnection. The i/f defines a method BeginTransaction() that returns an IDbTransaction. I want to define this as returning a DbTransaction (as...
6
by: Joseph Geretz | last post by:
I have the following class which I am serializing and passing back and forth between my Web Service application and the client. public class Token : SoapHeader { public string SID; public...
6
by: Jonathan Wood | last post by:
Although this will be a challenge at my level of ASP.NET knowledge, I'm thinking I should implement my own membership provider class. Looking over the methods I must implement, a number of...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.