473,320 Members | 1,910 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,320 software developers and data experts.

Public Constants

Hi,

what is a good way to implement public common constants. like what we do in
a common header file in C++.

jeff
Nov 17 '05 #1
2 1368
The c# compiler try to impose OO and dont let you declare variables if
they arnt member of class, delegate, enum, interface, or struct.

you can declare the constans as static readonly members :

public class Consts
{
public static readonly string MyName = "natty";
}

Natty Gur, CTO
Dao2Com Ltd.
28th Baruch Hirsch st. Bnei-Brak
Israel , 51114

Phone Numbers:
Office: +972-(0)3-5786668
Fax: +972-(0)3-5703475
Mobile: +972-(0)58-888377

Know the overall picture
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #2
Hi Guys,

Here is my suggestion and how I did it in VB :
1-Create a new Class Library project in VB
2-Delete the default class file
3-Add a new module
4-Here is code of module
Public Module Module1
Public Const MY_CONSTANT As String = "FDSFSD"
End Module
5-Compile the new project called constants2, which will give me a dll
(constants2.dll)
6-Create a new project called Test_constant
7-Add the constants2.dll in the bon directory of project Test_constant and
add reference to constants2.dll
9-And in page load of the starting page of Test_constant
Label1.Text = constants2.Module1.my_constant

And label shows "FDSFSD". So it seems to work.

I have not tried it but I beleive we can also put the dll in the GAC to
share it with all the applications.

"jeff" <i n d i a m e s s e n g e r@yahoo.com> wrote in message
news:O3*************@TK2MSFTNGP12.phx.gbl...
Hi,

what is a good way to implement public common constants. like what we do in a common header file in C++.

jeff

Nov 17 '05 #3

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

Similar topics

0
by: David W. Fenton | last post by:
Today I was working on a hideous old app that I created a long time ago that does a lot of showing/hiding/resizing of fields on one of the forms. I had used constants to store reference values for...
1
by: W1ld0ne [MCSD] | last post by:
We are writing a C#.net component that uses a VB.net component, that has a couple of public const's in it, but C# chooses not to see them. What's up with that. The only way we can get it to work is...
1
by: W1ld0ne [MCSD] | last post by:
We are writing a C#.net component that uses a VB.net component, that has a couple of public const's in it, but C# chooses not to see them. What's up with that. The only way we can get it to work is...
2
by: gwainguard | last post by:
Hello, would you please consider the following small piece of code. using System; class Constants { public const int A = B; public const int B = 2; }
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.