Article View: borland.public.csharpbuilder.language.csharp
Article #134Re: How can I create a static array of structure?
From: Marc Rohloff TeamB
Date: Fri, 01 Jun 2007 01:12
Date: Fri, 01 Jun 2007 01:12
42 lines
2061 bytes
2061 bytes
On 31 May 2007 08:37:48 -0700, A Nonymous wrote:
> struct TWidget
> {
> int MemAvail;
> int MemOffset;
> };
>
> static TWidget Widget[2] =
> {
> {0x100,0x200},
> {0x120,0x400}
> };
>
> In my app I can just refer to Widget[Model].MemAvail which will give me
> the amount of available memory for any model. When we release a new model,
> I just add a new layer to the array...
>
> How can I convert it to C#? So far I can find no syntax that works.
You could do something like:
struct TWidget
{
int MemAvail;
int MemOffset;
internal TWidget(int a, int o) { MemAvail = a; MemOffset = o;
}
};
class Program {
static TWidget[] Widget = {
new TWidget(1,2),
new TWidget(2,4)
};
--
Marc Rohloff [TeamB]
marc -at- marc rohloff -dot- com
Technical Details
Message-ID:
<btasag3eiguw$.dlg@dlg.marcrohloff.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<Xns99416C2344551anonymoushotmailcom@207.105.83.66>Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,d262dde1775b804b X-Google-Attributes: gid1efe35,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Marc Rohloff [TeamB]" <"on request"> Subject: Re: How can I create a static array of structure? Newsgroups: borland.public.csharpbuilder.language.csharp User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit References: <Xns99416C2344551anonymoushotmailcom@207.105.83.66> Date: Thu, 31 May 2007 21:12:16 -0400 Message-ID: <btasag3eiguw$.dlg@dlg.marcrohloff.com> X-Face: "huzh55Xi]!ZNni78>a*5+).`SK?<^q2MlHk-C]Z2M9T@\J5ZCB$95Ey+s"XQuhGFA[eutZ :0^AV!Q;t>gE`1-=8d;HZ6~*o1dH<X9\b$!|(}+I'!Xq)@3Op}%0ArW&nf'Qh*EwR X-Antivirus: avast! (VPS 000746-1, 05/31/2007), Outbound message X-Antivirus-Status: Clean NNTP-Posting-Host: 65.31.1.121 X-Trace: newsgroups.borland.com 1180660333 65.31.1.121 (31 May 2007 18:12:13 -0700) Lines: 42 X-Authenticated-User: mrohloff Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail