Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Fórum ➡ Example of a "crippled" extension method ♦
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; // aljodav ➡ rextester.com/users/376 // This code is related to the MSDN thread ➡ http://bit.ly/2oPGv27 namespace Rextester { public class Smtg{ public static Smtg Default(){ return new Smtg{One="-1-",Two="-2-"}; } public string One,Two; } public static class Util{ // EXAMPLE of a badly prototyped extension method: CRIPPLED EXTENSION METHOD. public static void Set(this Smtg first,ref Smtg second,Smtg third){ if(first==null||second==null||third==null)throw new Exception("..."); second.One=first.One; second.Two=third.Two; } } public class Program { public static void Write(string msg,Smtg a,Smtg def,Smtg c){ Console.WriteLine("Exposes the crippled extension method:\n" +"\t\ta ➡ {0} {1}\n" +"\t de_fault ➡ {2} {3}\n" +"\t\tc ➡ {4} {5}\n" +"({6})\n\n", a.One,a.Two, def.One,def.Two, c.One,c.Two, msg ); } public static void Main(string[] args) { Smtg a,de_fault,c; // 1 --------------------------------------- a=new Smtg{One="Quick",Two="Fox"}; de_fault=Smtg.Default(); c=new Smtg{One="HARD",Two="STEEL"}; // de_fault.Set(ref a,c); // crippled extension method // Write("Notice in the above, that \"a\" changed while \"de_fault\" was kept unchanged!" ,a,de_fault,c); // 2 ---------------------------------------- a=new Smtg{One="Quick",Two="Fox"}; de_fault=Smtg.Default(); c=new Smtg{One="HARD",Two="STEEL"}; // de_fault.Set(ref c,a); // crippled extension method // Write("Notice in the above, that \"c\" changed, while \"de_fault\" was kept unchanged!" ,a,de_fault,c); // - ------------------------------------------ Console.WriteLine("\nHello, world!"); } } }
run
|
edit
|
history
|
help
0
Jahongirochilov270@gmail.com
credentials
Get a webpage - the sync way
Code Challenege
operatoru
Exception
http://codegolf.stackexchange.com/questions/82526/sum-it-up-with-a-digital-triangle C# solution
Given a list of numbers and a number k, return whether any two numbers from the list add up to k
nested try catch
Stacks: Balanced Brackets