Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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


    jeff Guest

  2. Similar Questions and Discussions

    1. Sharing Constants in Multiple Applications - Public vs.Private
      I use private and public constants throughout my application to store hardcoded WSDL URLs and WebService methods. Many of these are the same in...
    2. ADO Constants
      I'm trying to transfer an intranet app from one server to another. I'm having a problem with the ADO constants on the destination server. Our...
    3. constants
      hi, why should I use constants? thx for help Michael
    4. ASP Constants
      Hi, In order to create an ADO connection and gets it running, I have to declare the ADO constants as : "<!-- METADATA TYPE = "Typelib" File =...
    5. Using Constants
      I'm considering using constants for some predefined paths in my script, like HTML_DIR, INC_DIR. These values won't change and they will be global...
  3. #2

    Default Re: Public Constants

    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 [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Natty Gur Guest

  4. #3

    Default Re: Public Constants

    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 [email]r@yahoo.com[/email]> wrote in message
    news:O3OOfswVDHA.384@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
    >
    >

    abacnet Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139