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!

Casts

Do not lose precision in an Implicit casts.

For example, there should NOT be an implicit cast from Double to Int32, but there may be one from Int32 to Int64.

Don’t throw exceptions from implicit casts because it will be very difficult for the developer to understand what is happening.

Do provide casts that operate on the whole object. The casted value represents the whole value being casted, not one sub part. For example, it is not appropriate for for a Button to a cast to string by returning it's caption.

Do use casts to convert a value into another value.

Do not generate a semantically different value.

For example it is appropriate to convert a Time or TimeSpan into an int. The int still represents the time or duration. It does not make sense to convert a file name string, e.g. "c:\mybitmap.gif" into a Bitmap object.

Do cast values are in the same domain. Don’t cast values from different domains. Casts operate within a particular domain of values. For example, numbers and strings are different domains. So it makes sense that an Int32 can cast to a double. It does not make sense for an int to cast to a string, because they are in different domains.