Programming Tips 💡
51.6K subscribers
67 photos
10 videos
30 files
354 links
Programming & AI:
Tips 💡
Articles 📕
Resources 👾
Design Patterns 💎
Software Principles

🇳🇱 Contact: @MoienTajik

🎯 Buy ads: https://telega.io/c/ProgrammingTip
Download Telegram
Extension Method

Home of 781 extension methods for C#, VB, F#, Swift, Kotlin and Javascript 💎

[ Website ] : http://www.extensionmethod.net/

#ExtensionMethod
@ProgrammingTip
5 More C# Extension Methods for the Stocking A Bonus Method For Enums ! 💥


1️⃣ ToInt()
We always have the familiar .ToString(), but what happens when we want to convert a simple string to an integer

🔹🔸🔹

2️⃣ OrdinalSuffix()
This extension method places a 'th', 'st', 'nd', 'rd', or 'th' to the end of the number. 🔚

🔸🔹🔸

3️⃣ Occurrence()
This just counts the number of occurrences in a string. 🔍

🔹🔸🔹

4️⃣ Join<T>()/Join()
With this extension method, you can take an array or List<string>() and make a comma-delimited list in no time or build a broken-up URL with dashes as the URL name.

🔸🔹🔸

5️⃣ ToQueryString()
Have you ever wanted to take a NameValueCollection and convert it into a query string for a URL ? 🌐

🔹🔸🔹

⚡️ Enums.ToList<T>() - Bonus Method

This Enums.ToList<T> static method is meant to take enumerations with description attributes and convert them into a NameValueCollection for possibly a dropdown. 📜

🔸🔹🔸

https://t.me/pgimg/96

[ Article ] : http://bit.do/chex


#CSharp #ExtensionMethod
@ProgrammingTip