Top "Extension-methods" questions

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

What is the easiest way to get the property value from a passed lambda expression in an extension method for HtmlHelper?

I am writing a dirty little extension method for HtmlHelper so that I can say something like HtmlHelper.WysiwygFor(lambda) …

asp.net-mvc recursion lambda extension-methods html-helper
Try-with-resources in Kotlin

When I tried to write an equivalent of a Java try-with-resources code in Kotlin, it didn't work for me. I …

kotlin extension-methods try-with-resources
Overriding ToString() of List<MyClass>

I have a class MyClass, and I would like to override the method ToString() of instances of List: class MyClass { …

c# string extension-methods overriding tostring
How to implement left join in JOIN Extension method

I am trying to implement an outer join on this kind of query for the p.Person table. How would …

c# linq extension-methods
C# Extension Method for Object

Is it a good idea to use an extension method on the Object class? I was wondering if by registering …

c# extension-methods
Why use TagBuilder instead of StringBuilder?

what's the difference in using tag builder and string builder to create a table in a htmlhelper class, or using …

c# asp.net-mvc extension-methods stringbuilder tagbuilder
Extension methods on a struct

Can you add extension methods to a struct?

c# .net struct extension-methods
How to access extension of UIColor in Swift?

I am very new to swift and trying to create an extension of UIColor class as extension UIColor{ func getCustomBlueColor() …

ios swift extension-methods uicolor
How to use IApplicationBuilder and IServiceCollection when downgrading from .NET Core 2.1 to .NET 4.7.1?

I had to change my project from .NET Core 2.1 to .NET 4.7.1 and I fixed almost all errors except the following …

c# asp.net asp.net-core extension-methods downgrade
Best practices: C# Extension methods namespace and promoting extension methods

I know there exists already a post, describing nearly the same, but I think mine is a bit different. What …

c# extension-methods