[Mono-dev] [Patch] TreeView, TreeNode, TreeNodeCollection

Carlos Alberto Cortez calberto.cortez at gmail.com
Tue Jan 9 18:33:50 EST 2007


> 
> > +		public virtual void RemoveByKey(string key)
> > +		{
> > +			int index = -1;
> > +			for (int i = 0; i < nodes.Count; i++)
> > +			{
> > +				if (!string.Equals(nodes[i].Name,key, StringComparison.CurrentCultureIgnoreCase))
> > +					continue;
> > +
> > +				index = i;
> > +				break;
> > +			}
> 
> Ditto. Additionally, what happens on MS.NET if you remove the
> String.Empty key? What happens if the collection has duplicate keys?
> Will be the keys deleted all together or just the first/last/random
> occurrence?

As far as I can tell, RemoveByKey behaves just like the other
Key-related methods, so when passing a null or empty string it should do
nothing.

Also, when having duplicate keys, the method should remove the first
occurrence (at least that happens with ListView related collections, for
example).

Anyway, the best thing do do, as Robert said, is to write tests.

Carlos.







More information about the Mono-devel-list mailing list