Can a C# method return a method? -


can method in c# return method?

a method return lambda expression example, don't know kind of type parameter give such method, because method isn't type. such returned method assigned delegate.

consider concept example:

public <unknown type> quadraticfunctionmaker(float , float b , float c) {     return (x) => { return * x * x  + b * x + c; }; }  delegate float function(float x); function quadraticfunction = quadraticfunctionmaker(1f,4f,3f); 

the types looking action<> or func<>.

the generic parameters on both types determine type signature of method. if method has no return value use action. if has return value use func whereby last generic parameter return type.

for example:

public void dosomething()                          // action public void dosomething(int number)                // action<int> public void dosomething(int number, string text)   // action<int,string>  public int dosomething()                           // func<int> public int dosomething(float number)               // func<float,int> public int dosomething(float number, string text)  // func<float,string,int> 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -