static void Main(string[] args) { Console.WriteLine("***** Extending Interface Compatible Types *****\n"); // System.Array реализует IEnumerable! string[] data = { "Wow", "this", "is", "sort", "of", "annoying", "but", "in", "a", "weird", "way", "fun!" }; data.PrintDataAndBeep(); Console.WriteLine(); // List<T> реализует IEnumerable! List <int> myInts = new List <int>() { 10, 15, 20 }; myInts.PrintDataAndBeep(); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("***** Extending Interface Compatible Types *****\n"); // System.Array implements IEnumerable! string[] data = { "Wow", "this", "is", "sort", "of", "annoying", "but", "in", "a", "weird", "way", "fun!" }; data.PrintDataAndBeep(); Console.WriteLine(); // List<T> implements IEnumerable! List <int> myInts = new List <int>() { 10, 15, 20 }; myInts.PrintDataAndBeep(); //// internet surfing ////Math math = new Math(); ////math. //Math2 math = new Math2(); //math. Console.ReadLine(); }
static void Main(string[] args) { string[] data = { "This", "is", "annoying" }; data.PrintDataAndBeep(); Console.WriteLine(); List<int> myInts = new List<int>() { 10, 15, 20 }; myInts.PrintDataAndBeep(); Console.ReadLine(); }
public static void TextAnnoyingExtensions() { Console.WriteLine("Extending interface compatible types"); string[] data = {"Wow", "this", "is", "sort", "of", "annoying", "but", "in", "a", "weird", "way", "fun"}; data.PrintDataAndBeep(); Console.WriteLine(); // List<t> implements IEnumerable! List<int> myInts = new List<int>() {10, 15, 20}; myInts.PrintDataAndBeep(); }
static void Main(string[] args) { Console.WriteLine("***** Extending Interface Compatible types *****\n"); string[] data = { "Wow", "this", "is", "sort", "of", "annoying", "but", "in", "a", "weird", "way", "fun!" }; data.PrintDataAndBeep(); Console.WriteLine(); List <int> myInts = new List <int>() { 10, 15, 20 }; myInts.PrintDataAndBeep(); }
static void ExtendInterface() { Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("=> Entending Interface Compatible Types"); string[] data = { "Wow", "this", "is", "sort", "of", "annoying", "but", "in", "a", "weird", "way", "fun!" }; data.PrintDataAndBeep(); Console.WriteLine(); List <int> ints = new List <int> { 10, 15, 20 }; ints.PrintDataAndBeep(); }
static void Main(string[] args) { Console.WriteLine("******Extending interface compatible types *******"); string[] data = { "wow", "this", "is", "sort", "of", "annoying" }; data.PrintDataAndBeep(); Console.WriteLine(); List <int> myInts = new List <int>() { 1, 2, 3 }; myInts.PrintDataAndBeep(); Console.Read(); }
static void Main(string[] args) { Console.WriteLine("***** Extending Interface Compatible Types *****\n"); // System.Array implemnets IEnumerable! string[] data = {"Wow", "this", "is", "sort", "of", "annoying", "but", "in", "a", "wierd", "way", "fun!"}; data.PrintDataAndBeep(); Console.WriteLine(); // List<T> implements IEnumerable! List<int> myInts = new List<int>() { 10, 15, 20 }; myInts.PrintDataAndBeep(); Console.ReadLine(); }
static void Main(string[] args) { Console.WriteLine("**** Extending Interface Compatible Type ****"); //syatem.array implements IEnumerable string[] data = { "Wow", "this", "sort", "of", "annoying", "but", "in", "a", "wierd", "way", "fun" }; data.PrintDataAndBeep(); Console.WriteLine(); //List implements IEnumerable List <int> myInt = new List <int> { 10, 15, 20 }; myInt.PrintDataAndBeep(); Console.Read(); }
/// <summary> /// Extending Interface Compatible Types /// </summary> private void InterfaceExtensions() { Console.WriteLine("=> Extending Interface Compatible Types: "); // System.Array implements IEnumerable string[] data = { "Wow", "this", "is", "sort", "of", "annoying", "but", "in", "a", "weird", "way", "fun!" }; data.PrintDataAndBeep(); Console.WriteLine(); // List<T> implements IEnumerable List <int> myInts = new List <int>() { 10, 15, 20 }; myInts.PrintDataAndBeep(); Console.WriteLine(); }
public static void Main(string[] args) { Console.WriteLine("Extending Interface Compatible types"); // System.Array implements IEnumerable string[] data = { "just", "some", "random", "strings" }; data.PrintDataAndBeep(); Console.WriteLine(); // List<T> implements IEnumerable List <int> myInts = new List <int>() { 10, 15, 20 }; myInts.PrintDataAndBeep(); Console.ReadLine(); }
static void ExtendInterfaceCompatibleTypes() { System.Console.WriteLine("=> extend interface compatible types:"); string[] data = { "Wow", "this", "is", "sort", "of", "annoying", "but", "in", "a", "weird", "way", "fun!" }; data.PrintDataAndBeep(); System.Console.WriteLine(); // List<T> implements IEnumerable List <int> myInts = new List <int>() { 10, 15, 20 }; myInts.PrintDataAndBeep(); Console.ReadLine(); }
public static void Test() { Console.WriteLine("********* Invoking Extension Methods *********\n"); string str1 = "Moamen"; // use string Extension Method with strings only, // and if you try another type you will face Compiler Error Console.WriteLine($@"str1.Repeat(3): {str1.Repeat(3)}"); Console.WriteLine($@"str1.Repeat(4): {str1.Repeat(4)}"); Console.WriteLine($@"str1.Repeat(5): {str1.Repeat(5)}"); Console.WriteLine($@"""Hello"".Repeat(3): {"Hello".Repeat(3)}"); int num = 12345; // use int Extension Method with ints only, // and if you try another type you will face Compiler Error Console.WriteLine($@"num.ReverseDigits(): {num.ReverseDigits()}"); // use object Extension Method with strings and ints,...etc any type; Console.WriteLine($@"str1.GetObjectInfo(): {str1.GetObjectInfo()}"); Console.WriteLine($@"num.GetObjectInfo(): {num.GetObjectInfo()}"); Console.WriteLine("***** Extending Interface Compatible Types *****\n"); // System.Array implements IEnumerable! string[] data = { "Wow", "this", "is", "sort", "of", "annoying", "but", "in", "a", "weird", "way", "fun!" }; data.PrintDataAndBeep(); Console.WriteLine(); // List<T> implements IEnumerable! List <int> myInts = new List <int>() { 10, 15, 20 }; myInts.PrintDataAndBeep(); }
public static void Main() { Console.Title = "Пример использования расширенных методов, реализующих интерфейс"; Console.ForegroundColor = ConsoleColor.Yellow; /* * Применим расширяемые методы на классы, * реализующие интерфейс IEnumerable */ var myList = new List <int> { 5, 10, 15, 20, 26, 248, 12, 5, 10, 5, 1 }; myList.PrintDataAndBeep(); Console.WriteLine(); var stringList = new List <string> { "Johny", "Margo", "Someone" }; stringList.PrintDataAndBeep(); Console.ReadLine(); }