Top "Extension-methods" questions

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

What's the Best Way to Add One Item to an IEnumerable<T>?

Here's how I would add one item to an IEnumerable object: //Some IEnumerable<T> object IEnumerable<string&…

c# extension-methods ienumerable
How do I use Moq to mock an extension method?

I am writing a test that depends on the results of an extension method but I don't want a future …

c# mocking moq extension-methods
Get attribute values from matching XML nodes using XPath query

This doesn't seem like it should be difficult, but I'm stuck currently. I'm trying to get the attribute values for …

c# xml extension-methods xpath xpathnavigator
Can extension methods be applied to interfaces?

Is it possible to apply an extension method to an interface? (C# question) That is for example to achieve the …

c# .net interface extension-methods
Is there any method like ForEach for IList?

Possible Duplicate: LINQ equivalent of foreach for IEnumerable<T> List<T> has a method called ForEach …

c# linq extension-methods
Pass a lambda expression in place of IComparer or IEqualityComparer or any single-method interface?

I happened to have seen some code where this guy passed a lambda expression to a ArrayList.Sort(IComparer here) …

linq extension-methods ienumerable iequalitycomparer icomparer
How to use Active Support core extensions

I have Active Support 3.0.3 installed and Rails 3.0.3 with Ruby 1.8.7. When I try to use 1.week.ago I get NoMethodError: undefined …

ruby-on-rails ruby time extension-methods activesupport
In C#, what happens when you call an extension method on a null object?

Does the method get called with a null value or does it give a null reference exception? MyObject myObject = null; …

c# parameters null extension-methods
Operator Overloading with C# Extension Methods

I'm attempting to use extension methods to add an operater overload to the C# StringBuilder class. Specifically, given StringBuilder sb, …

c# extension-methods operator-overloading
Code equivalent to the 'let' keyword in chained LINQ extension method calls

Using the C# compilers query comprehension features, you can write code like: var names = new string[] { "Dog", "Cat", "Giraffe", "Monkey", "…

c# linq extension-methods linq-to-objects