Problem I’m creating an extension method that can be used on any type. The idea is that if this method […]
Tag: extension-methods
Getting the value of a custom attribute from an enum
Problem Suppose we have an enum called “Planet” and it has a custom attribute of class “PlanetAttr”, these methods will […]
Int extension for translating integer to plain English
Problem This code was inspired by this question: Number to Words import Foundation extension Int { func plainEnglish (negativeSign: String […]
Checking if an array is initialized and allocated in VB.NET
Problem I am creating an add-in for a piece of software our company uses, so I’m working pretty extensively with […]
Adding extension methods to IServiceCollection in ASP.NET Core
Problem I have the following extension method to add themes support to my application: public static void AddThemes(this IServiceCollection services, […]
regex string extension
Problem I wrote some string-extensions: public static class RegexStringExtensions { public static string PatternReplace( this string seed, string pattern, Func<string, […]
Helper method to shuffle cards list for online gaming
Problem I have written this code to shuffle a deck of cards. I would like to hear your inputs. public […]
Pass class property as parameter to extension method
Problem I have the following class structure: MyAttribute.cs public sealed class MyAttribute : Attribute { public MyAttribute(string name) { if […]
Grouping by sequence in LINQ
Problem Suppose a series of objects (presented here as tuples): “a” | 1 “a” | 2 “b” | 3 “b” […]
How to divide a large method into 2 smaller methods [closed]
Problem Closed. This question is off-topic. It is not currently accepting answers. Code not implemented or not working as intended: […]