Article View: borland.public.csharpbuilder.language.csharp
Article #152True Constants in C# ?
From: Dr. Bob Miller
Date: Tue, 29 Aug 2006 02:47
Date: Tue, 29 Aug 2006 02:47
31 lines
2394 bytes
2394 bytes
I am a longtime programmer in many other languages (Delphi, C/C++, VB, VB.NET, etc), but am brand new to C#. I am particularly puzzled by how to really use constants. In most object oriented languages, there are obvious ways of creating true constants that have a lifetime that is the lifetime of the whole application, live outside of any object, are visible by code in other files, and usable within multiple objects. In C#, by contrast, I am getting the impression that a constant may only be defined inside a classe, so that you have to create an object of that class first, then reference the constant as being a member of that class. Is my impression wrong? All I am trying to do is to make a separate file that contains some constants that live outside of any objects (so I don't have to create some object before I can use the constant), and which constants are visible from code in multiple objects. In other words, like one would do with a C header file that only included constant declarations. I haven't been able to find any examples of how to do this in C#: every code example that I have seen that even uses constants seems to create them inside a class. Is it possible to create and use true constants in C#? If so, could someone scratch out a crude 10-line outline of an example? I'd really appreciate it! Best regards, Dr. Bob Miller Trace Systems, Inc.
Technical Details
Message-ID:
<44f3aab7$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,1326b8d2515daa80,start X-Google-Attributes: gid1efe35,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Dr. Bob Miller" <drbob@tracesystemsinc.com> From: "Dr. Bob Miller" <drbob@tracesystemsinc.com> Newsgroups: borland.public.csharpbuilder.language.csharp Subject: True Constants in C# ? Date: Mon, 28 Aug 2006 22:47:18 -0400 Lines: 33 Organization: Trace Systems, Inc. X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-RFC2646: Format=Flowed; Original NNTP-Posting-Host: 68.48.46.9 Message-ID: <44f3aab7$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1156819639 68.48.46.9 (28 Aug 2006 19:47:19 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail