🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.csharpbuilder.language.csharp
Article #156

Re: True Constants in C# ?

#156
From: Bob Dawson
Date: Tue, 29 Aug 2006 18:55
23 lines
2024 bytes
"Dr. Bob Miller" wrote
> OK, I get the picture. "Static" at least allows you to avoid having to
> instantiate a class.

Yep. "Static" in C# is similar to "class" in a Delphi method declaration,
though there are a couple of differences in how class-level and
instance-level stuff works.

> You still have to refer to the "constant" with the name of the class it is
> defined in, I see.

Yeah, but like I said, just look at that as an organizational tool. You just
write MathConstants. or FinanceConstants. or YourDomainConstants. and let
code completion take over. the fact that it's a class really doesn't matter
that much.

>   public static double Pi = 3.1427;

Like Joanna said, specify "readonly", but otherwise that's going to work the
same. I have an old OO-ers tic of never declaring public fields, though in
this case there's really nothing wrong with it.

bobD
Technical Details
Message-ID: <44f48da4$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <44f3aab7$1@newsgroups.borland.com> <44f3b155$1@newsgroups.borland.com> <44f44eba$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,1326b8d2515daa80
X-Google-Attributes: gid1efe35,public
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Bob Dawson" <bdawson@idtdna.com>
From: "Bob Dawson" <bdawson@idtdna.com>
Newsgroups: borland.public.csharpbuilder.language.csharp
References: <44f3aab7$1@newsgroups.borland.com> <44f3b155$1@newsgroups.borland.com> <44f44eba$1@newsgroups.borland.com>
Subject: Re: True Constants in C# ?
Date: Tue, 29 Aug 2006 13:55:33 -0500
Lines: 25
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1807
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807
NNTP-Posting-Host: 209.152.114.253
Message-ID: <44f48da4$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1156877732 209.152.114.253 (29 Aug 2006 11:55:32 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!colt.net!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail