Top "Extension-methods" questions

An extension method is a language feature of some languages, such as Swift, Visual Basic.

Partial Class vs Extension Method

I dont have much experience of using these 2 ways to extend a class or create extension methods against a class. …

c# extension-methods partial-classes
Doesn't C# Extension Methods allow passing parameters by reference?

Is it really impossible to create an extension method in C# where the instance is passed as a reference? Here’…

c# vb.net extension-methods byref
What does 'this' keyword mean in a method parameter?

namespace System.Web.Mvc.Html { // Summary: // Represents support for HTML in an application. public static class FormExtensions { public static MvcForm …

c# extension-methods html-helper
What causes "extension methods cannot be dynamically dispatched" here?

Compile Error 'System.Data.SqlClient.SqlConnection' has no applicable method named 'Query' but appears to have an extension method by …

c# .net compiler-errors extension-methods dapper
Why is the 'this' keyword required to call an extension method from within the extended class

I have created an extension method for an ASP.NET MVC ViewPage, e.g: public static class ViewExtensions { public static …

c# extension-methods
Why doesn't the Controls collection provide all of the IEnumerable methods?

I'm not for sure how the ControlCollection of ASP.Net works, so maybe someone can shed some light on this …

c# asp.net linq extension-methods ienumerable
Impossible to use ref and out for first ("this") parameter in Extension methods?

Why is it forbidden to call Extension Method with ref modifier? This one is possible: public static void Change(ref …

c# .net extension-methods
Can I add an implicit conversion for two classes which I don't directly control?

I'd like to be able to implicitly convert between two classes which are otherwise incompatible. One of the classes is …

c# f# operator-overloading extension-methods implicit-conversion
How to resolve dependency in static class with Unity?

I have the following extension method, which exists (naturally) in a static class. public static class MyExtensions { [Dependency] private static …

c# unity-container extension-methods
Evil use of Maybe monad and extension methods in C#?

edit 2015 This question and its answers are no longer relevant. It was asked before the advent of C# 6, which has …

c# extension-methods monads