Top "Extension-methods" questions

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

Distinct() with lambda?

Right, so I have an enumerable and wish to get distinct values from it. Using System.Linq, there's of course …

c# c#-3.0 lambda extension-methods
Extension methods must be defined in a non-generic static class

I'm getting the error: Extension methods must be defined in a non-generic static class On the line: public class LinqHelper …

c# .net linq extension-methods compiler-errors
Convert string[] to int[] in one line of code using LINQ

I have an array of integers in string form: var arr = new string[] { "1", "2", "3", "4" }; I need to an array of 'real' …

c# .net linq extension-methods
Does C# have extension properties?

Does C# have extension properties? For example, can I add an extension property to DateTimeFormatInfo called ShortDateLongTimeFormat which would return …

c# properties extension-methods
Can I add extension methods to an existing static class?

I'm a fan of extension methods in C#, but haven't had any success adding an extension method to a static …

c# static extension-methods
Which method performs better: .Any() vs .Count() > 0?

in the System.Linq namespace, we can now extend our IEnumerable's to have the Any() and Count() extension methods. I …

.net linq performance .net-3.5 extension-methods
Why there is no ForEach extension method on IEnumerable?

Inspired by another question asking about the missing Zip function: Why is there no ForEach extension method in the Enumerable …

c# .net vb.net extension-methods
How do I extend a class with c# extension methods?

Can extension methods be applied to the class? For example, extend DateTime to include a Tomorrow() method that could be …

c# extension-methods
Convert string to nullable type (int, double, etc...)

I am attempting to do some data conversion. Unfortunately, much of the data is in strings, where it should be …

c# .net generics extension-methods type-conversion
What are your favorite extension methods for C#? (codeplex.com/extensionoverflow)

Let's make a list of answers where you post your excellent and favorite extension methods. The requirement is that the …

c# .net open-source extension-methods