Advantages of using extension methods in functional programming
Method chaining in functional programming relies on extension methods. As we have already discussed in Chapter 1, Tasting Functional Style in C#, method chaining will make our code easier to read since it can decrease the lines of code. For the sake of code readability in the extension method, let's take a look at the following code, which we can find in the CodeReadability.csproj
project:
using System.Linq; namespace CodeReadability { public static class HelperMethods { public static string TrimAllSpace(string str) { string retValue = ""; foreach (char c in str) { retValue +=!char.IsWhiteSpace(c) ?c.ToString() :""; } return retValue; } public static string Capitalize(string str) { string retValue = ""; string[] allWords = str.Split(' '); foreach...