Article View: borland.public.csharpbuilder.language.csharp
Article #573Re: ArrayList get problem.
From: Marc Rohloff TeamB
Date: Wed, 11 Aug 2004 11:18
Date: Wed, 11 Aug 2004 11:18
44 lines
2555 bytes
2555 bytes
On Wed, 11 Aug 2004 09:01:48 +0100, JRobert wrote:
> Case 1.
> If the Static modifier infront ArrayList is missing then i get the
> error:
> [C# Fehler] m68k.cs(714): 'madis.m68kDisassembler.OPCodeGroups' deutet
> auf 'Feld' hin, wo 'Klasse' erwartet wurde
> English: 'madis.m68kDisassembler.OPCodeGroups' points on an Array where
> a Class is beeing expected.
A static method doesn't require an instance of a class to be executed
so it can only access fields and methods defined as static.
> Case 2.
> Including the static modifier gives the error you've mentioned.
> [C# Fehler] m68k.cs(714): 'System.Collections.ArrayList' enth�lt keine
> Definition f�r 'Item'
Yes, as I said this is not legal syntax for c# you need to remove the
'dotItem' part.
> public class m68kDisassembler
> {
> private static OPCODE_NODE[] curOpcode;
> public m68kDisassembler()
> public static string disassemble(byte[] memptr, uint index, out uint
This isn't correct. You have defined curOpCode so that it is static
but then you are initializing it once every time you create the class
(ie in the constructor).
Also disassemble is static so it can be called without an instance
which means the curOpcode array might never have been initialised.
You probably want to make the constructor static too ie change
> public m68kDisassembler()
to
public static m68kDisassembler()
Lastly since you probably know the number of elements in the arraylist
why don't you just use a normal array. This would produce faster code.
--
Marc Rohloff [TeamB]
marc rohloff at myrealbox dot com
Technical Details
Message-ID:
<1gipscpbtb2f$.dlg@marcrohloff.40tude.net>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<411910a7$1@newsgroups.borland.com> <1g4pi3sjwhqr7.dlg@marcrohloff.40tude.net> <4119c4b5$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 1efe35,e82952e970601dc8 X-Google-Attributes: gid1efe35,public X-Google-Language: ENGLISH,ASCII From: "Marc Rohloff [TeamB]" <"on request"> Subject: Re: ArrayList get problem. Newsgroups: borland.public.csharpbuilder.language.csharp User-Agent: 40tude_Dialog/2.0.12.1 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit References: <411910a7$1@newsgroups.borland.com> <1g4pi3sjwhqr7.dlg@marcrohloff.40tude.net> <4119c4b5$1@newsgroups.borland.com> Date: Wed, 11 Aug 2004 07:18:03 -0400 Message-ID: <1gipscpbtb2f$.dlg@marcrohloff.40tude.net> NNTP-Posting-Host: 4.131.36.176 X-Trace: newsgroups.borland.com 1092223057 4.131.36.176 (11 Aug 2004 04:17:37 -0700) Lines: 44 X-Authenticated-User: mrohloff Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail