Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

ArrayList error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Rogers - 09 Mar 2008 01:40 GMT
How do I fix this error?

       ArrayList customerArray = new ArrayList();
       customerArray.Add("Tester");
       customerArray.Add("Testing");

Error 1 Invalid token '(' in class, struct, or interface member declaration
222 26

Thanks
Arne Vajhøj - 09 Mar 2008 01:54 GMT
> How do I fix this error?
>
[quoted text clipped - 4 lines]
> Error 1 Invalid token '(' in class, struct, or interface member declaration
> 222 26

Sounds as if you have put some code that belong inside
a method outside a method.

Arne
John Rogers - 09 Mar 2008 02:25 GMT
I dont get what you are saying, because if I do this

ArrayList someList = new ArrayList();
someList.Add("test");

I will get the same error.

>> How do I fix this error?
>>
[quoted text clipped - 9 lines]
>
> Arne
Arne Vajhøj - 09 Mar 2008 02:45 GMT
>>> How do I fix this error?
>>>
[quoted text clipped - 12 lines]
>
> I will get the same error.

Look at this:

C:\>type z1.cs
using System;
using System.Collections;

public class Z1
{
    ArrayList customerArray = new ArrayList();
    customerArray.Add("Tester");
    customerArray.Add("Testing");
}

C:\>csc /t:library z1.cs
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.1433
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.

z1.cs(7,22): error CS1519: Invalid token '(' in class, struct, or interface
        member declaration
z1.cs(8,22): error CS1519: Invalid token '(' in class, struct, or interface
        member declaration

C:\>type z2.cs
using System;
using System.Collections;

public class Z2
{
    public void Foobar()
    {
       ArrayList customerArray = new ArrayList();
       customerArray.Add("Tester");
       customerArray.Add("Testing");
    }
}

C:\>csc /t:library z2.cs
Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.1433
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.

C:\>

Arne
Mike - 09 Mar 2008 02:54 GMT
> How do I fix this error?
>
[quoted text clipped - 6 lines]
>
> Thanks

John, can you post the complete code for this c# class. I see nothing
wrong with this code, so I expect something is wrong with the class/
method definition.

Regards, Mike...

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.