NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Arrays vs. Collections

Class library designers are sometimes faced with a decision about when to use an arrays and when to return a collection. These solutions have very similar usage models; but somewhat different performance characteristics.

Collection

Do use a collection when Add, Remove or other methods for manipulating the collection are supported. This scopes all related methods to the collection.

Do use collections to add readonly wrappers around internal arrays.

Indexed Properties in Collections

Use only as the default member of a collection class or interface.

Do not create families of functions like this. Use a collection instead.

int FooCount { get; }
SomeType Foo[int index] { set; get; }
void ApppendFoo(SomeType foo)

Array Valued Properties

Recommendation using collections to avoid the inefficiencies in the following naive code:

for (int i = 0; i < obj.Foo.Count; i++)
      DoSomething(obj.Foo[i])