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

G

Guest

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.
 
P

Peter Thornqvist

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top