Results 1 to 2 of 2

Thread: Code in 1.1 That doesn't work in 2.0

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2003
    Location
    Eden Prairie Minnesota
    Posts
    301

    Code in 1.1 That doesn't work in 2.0

    Here is the code that gives me trouble:

    Code:
            m_alFriends = ArrayList.Synchronized(new ArrayList(25));
    I Declared m_alFriends like so:

    Code:
            private List<Friends.Friend> m_alFriends;
    I changed that from:

    Code:
            private ArrayList m_alFriends;
    I get the following error:

    Code:
    Error	7	Cannot implicitly convert type 'System.Collections.ArrayList' to 'System.Collections.Generic.List<Defiance.Bncs.Friends.Friend>'	C:\Documents and Settings\JoeL Zimmerman\My Documents\My Programming\C#\8.0\Defiance\Defiance.Connection\BNCS\OpenGameProtocol.cs	764	31	Defiance.Connections
    Last edited by BaDDBLooD; Apr 8th, 2006 at 04:37 PM.
    There are only two kinds of people who are truely fascinating: people who know absolutely everything, and people who know absolutely nothing.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Code in 1.1 That doesn't work in 2.0

    The ArrayList and the Generic.List(Of T) are completely different types. You cannot create a synchronised ArrayList and assign it to a Generic.List(Of T) variable. You need to create a synchronised Generic.List(Of T). The Generic.List(Of T) type doesn't have a Synchronized method though, so I'm not sure if it's possible. You may have to use lock statements to manually synchronise access to your collection.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width