Extension methods, nulls, namespaces and precedence in c#
- 308 views
Extension methods are the most controversial feature that Microsoft has introduced in ...
Extension methods are the most controversial feature that Microsoft has introduced in
C# 3.0. Introduced to support the LINQ query framework, extension methods make
it possible to define new methods for existing classes.
Although extension methods can greatly simplify code that uses them, many are
concerned that they could transform C# into something that programmers find
unrecognizable, or that C#’s namespace mechanisms are inadequate for managing
large systems that use extension methods. Adoption of the LINQ framework,
however, means that extension methods are here to stay, and that .net
programmers need to understand how to use them effectively, and, in particular,
how extension methods are different from regular methods.
This article discusses three ways in which extension methods differ from regular
1. Extension methods can be called on null objects without throwing an exception
2. Extension methods cannot be called inside of a subclass
- Total Views
- Views on SlideShare
- Embed Views