C# : how to create delegate type from delegate types? -


In C #, how can one create a representative type that maps to the representative type for a representative type? Specifically, in my example given below, I want to declare a representative code (yoga) (borrowing from mathematical notation) yoga (f, g) = f + g . I then use yoga (f, g) - such as yoga (f, g) (5) [this meaning f (5) + g (5) ].

  class examples {representative int IntToInt (int i); Public fixed integer double (int i) {return i * 2; } Public Stable Ent Square (Int i) {return i * i; } Representative IntToInt IntToIntPair_To_IntToInt (IntToInt f, IntToInt g); Public Static IntToInt Sum (IntToInt f, IntToInt, g) {Return f + g; } Public static zero main () {IntToInt DoubleInstance = Double; IntToInt SquareEninstance = Square; IntToIntPair_To_IntToInt SumInstance = Amount; System Console Limit (double instance, square instance) (5)); // / 35 = 10 + 25 = Double (5) + Square (5)}}  

  function  

Funk & lt; Int, int>, funk & lt; Int, int & gt; & Gt;

represents a function, which takes one (to convert the function to a second int) and gives one (the function to convert the second int to the function). Or two to return to work and one-third return:

  FUNX & lt; Funk & lt; Int, int>, fax & lt; Int, int>, funk & lt; Int, int & gt; & Gt;  

For example:

  function & lt; Funk & lt; Int, int>, funk & lt; Int, int & gt; & Gt; ApplyTwice = (f => gt = & gt; f (f (x));  

It can be returned normally by any method:

  Func & lt; T; T & gt; Func & lt; T, ==== Func (func (x))}}  

If you want to add two functions, then you can:

  public Fixed Func & lt; int, int & gt; Yoga (fx & lt; int, int> first, fx; int, int & gt; second) {return x => first (x) + second (X);}  

To apply it now:

  F & lt; int, int & gt; ; Doubler = x => x * 2; function; lt; int, int> squarer = x = & gt; x * x; funk & lt; int, int gt; doubleplusquare = even (duplicate, square Console WriteLine (DoubleSpaceSquare (5)                

TResult & gt; (); Public Representative TResult Func & lt; T, TResult & gt; (T arg); Public Representative Trial Fx & lt; T1, T2, Trashlecht & gt; (T1 AGR1, T2RG2);

(I have more.)

Then you have to use anonymous methods, such as

  public stable Function & lt; Int, int & gt; (Fax and lieutenium; int, et; g; first, funk and lethinum; int, et; gt; second) {return representative (xx) • return first (x) + second (x); }; } Fx & lt; Int, int & gt; Doubler = delegate (int x) {return x * 2; }; Function & lt; Int, int & gt; Squarer = delegate (int x) {return x * x; }; Function & lt; Int, int & gt; DoubleSpaceSquare = Sum (Dueler, Worker); Console.WriteLine (doublePlusSquare (5)); // print 35  

Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -