I'm new to mono, and trying to get my existing .NET application to run.  I'm 
having a problem with a difference in the behavior of generic lists.  Please 
can someone help me out?  Am I being stupid?  Or should I raise a bug?

In Mono, if a writable list is accessed as an IList, it appears to be treated 
as readonly.  Here is a minimal program that works fine under .NET:

using System;
using System.Collections.Generic;

namespace MonoTest
{
  class Program
  {
    static void Main(string[] args)
    {
      IList<int> lList = new int[2];
      lList[0] = 1;
    }
  }
}


But gives the following exception in mono:

Unhandled Exception: System.NotSupportedException: Collection is read-only
  at System.Array.InternalArray__set_Item[Int32] (Int32 index, Int32 item) 
[0x00000]
  at (wrapper managed-to-managed) 
System.Int32[]:System.Collections.Generic.IList`1.set_Item (int,int)
  at MonoTest.Program.Main (System.String[] args) [0x00000]

Many thanks
Adam




      ___________________________________________________________
Support the World Aids Awareness campaign this month with Yahoo! For Good 
http://uk.promotions.yahoo.com/forgood/
_______________________________________________
Mono-list maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list

Reply via email to