B. Validating Method Parameters
WITH XML COMMENTS, we can annotate our methods with information on the parameters we expect and their valid range of values using the param
element and its attributes. However, the param
element is informational only and does not enforce the requirements it specifies in its markup. If a parameter was expected to be a non-null integer, we could pass a null or a string in on that parameter, and our method would happily accept the parameter. To us .NET statically typed developers, this is undesirable because the method might behave unexpectedly with unexpected values for inputs. Microsoft must have felt the same way and built a mechanism to perform parameter checking at the beginning of the method that we can use, ...
Get Advanced ASP.NET AJAX Server Controls For .NET Framework 3.5 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.