| Dua Ali
Extension methods are, as the name implies, additional methods. Extension methods allow you to inject additional methods into a class or interface without having to alter, derivate, or recompile it. Extension methods can be added to your own custom class, .NET framework classes, or third party classes or interfaces.
For better understanding, here is an example project showing that how we can implement extension methods in C#.
Step 1: Open Visual Studio 2019, and create a new project by selecting Console Application.
Step 2: Provide a name to the project and click Next.
Step 3: Add an empty class to your project and name it. Here I have named it ‘TimeZoneAbbreviation’. Note that it is a static class as we are going to make extension method which itself is a static method. There is also a this keyword succeeded by a string data type that syntactically shows that it is an extension method.
Step 4: We can now call our extension method in our Main method.
Step 5: The console shows the final result. The string ‘CST’ is converted into its full form after it is passed to the extension method. In this way, we can use extensions with different implementations.
Join us next time, as we continue our journey of learning canvas apps.Click here to learn more about Imperium's Power Apps Services. We hope this information was useful, and we look forward to sharing more insights into the Power Platform world.