I am looking to implement a functionality in a list of object as I would in C# using an extension method. Something like this: List<DataObject> list; // ... List...
Using the C# compilers query comprehension features, you can write code like: var names = new string { "Dog", "Cat", "Giraffe", "Monkey", "Tortoise" }; var result = from animalName...
I have a preexisting Interface… public interface ISomeInterface { void SomeMethod(); } and I’ve extended this intreface using a mixin… public static class SomeInterfaceExtensions { public static void AnotherMethod(this...
I’m getting the error: Extension methods must be defined in a non-generic static class On the line: public class LinqHelper Here is the helper class, based on Mark Gavells...
I have an array of integers in string form: var arr = new string { "1", "2", "3", "4" }; I need to an array of ‘real’ integers to...
Does the method get called with a null value or does it give a null reference exception? MyObject myObject = null; myObject.MyExtensionMethod(); // <-- is this a null reference...
Inspired by another question asking about the missing Zip function: Why is there no ForEach extension method on the IEnumerable interface? Or anywhere? The only class that gets a...
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. Let’s make a...
I’m a fan of extension methods in C#, but haven’t had any success adding an extension method to a static class, such as Console. For example, if I want...
in the System.Linq namespace, we can now extend our IEnumerable’s to have the Any() and Count() extension methods. I was told recently that if i want to check that...