Created
April 19, 2019 17:43
-
-
Save kostapc/2c440c036be97a72b75ad015d8b12f60 to your computer and use it in GitHub Desktop.
C# extensions methods example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
namespace FunctionalExperiments | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
SomeEmptyClass someObject = new SomeEmptyClass(); | |
someObject.NewEmptyMethod(); | |
string some = "aaaa"; | |
some.NewMethod(); | |
Console.ReadKey(); | |
} | |
} | |
public static class StringExtensions | |
{ | |
public static void NewMethod(this String self) | |
{ | |
Console.WriteLine("hello here, i am " + self); | |
} | |
} | |
public static class SomeEmptyClassExtensions | |
{ | |
public static void NewEmptyMethod(this SomeEmptyClass self) | |
{ | |
Console.WriteLine("hello here"); | |
} | |
} | |
public class SomeEmptyClass | |
{ | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment