[Mono-list] compile problem and indexer resizing

Jonathan Pryor jonpryor@vt.edu
18 Feb 2003 06:58:16 -0500


To answer your question, yes, this is wrong:

	myAccounts[].Add (account);

For one thing, there should be something within the indexer brackets to
be syntactically valid (by my understanding of the language), and the
return type of myAccounts[] should be of type "Account", which
(presumably) doesn't have an Add(Account) method.

So the "Add(account)" should also generate an error.

If this compiles with no problems, I would suggest filing a bug report
at http://bugzilla.ximian.com under the mcs module.

 - Jon

On Mon, 2003-02-17 at 23:02, John BouAntoun wrote:
> Don't know about the compiler complaining, but you should look into using an ArrayList (System.Collections) instead of a regular array.
> 
> -----Original Message-----
> From: Santiago Erquicia [mailto:serquicia@fibertel.com.ar]
> Sent: Tuesday, 18 February 2003 2:50 PM
> To: mono-list@lists.ximian.com
> Subject: [Mono-list] compile problem and indexer resizing
> 
> 
> I'm new to C# and programing in general.  I was trying to resize an indexer 
> (by the way, does anybody know how to do that?) and when I tried to compile 
> it, my CPU usage jumped to 98% and never ended.
> 
> This is the code:
> 
> 	class AccountList
> 	{
> 		private Account[] myAccounts;
> 		private int last;
> 
> 		public AccountList(int length)
> 		{
> 			this.myAccounts = new Account[length];
> 		}
> 
> 		/* Indexer */
> 		public Account this[int index]
> 		{
> 			get
> 			{
> 				return myAccounts[index];
> 			}
> 		}
> 
> 		public int Add (Account account)
> 		{
> 			myAccounts[].Add(account);
> 			return this.last;
> 		}
> 	}
> 
> Does anyone knows if this is wrong? If it is, shoudn't the compiler say 
> something?
> 
> Thanks,
> Santiago
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list