function - Understadning C# delegate Func<...> operators -


i having trouble on understanding c# func<...> operators, example, have following snippet:

func<int, bool> = n => n <= 1; func<int, int> b = n => 10; func<int, int> c = n => { return n; }; func<int, int> d = n => a(n)? b(n): n*c(n-1); console.writeline("{0} {1} {2}", d(1), d(2), d(3)); 

what meaing of ? , : stand ? a(n)? b(n) stand condition ? (e.g. if a(n) false , b(n) has value, calculate c(n) , return d.) not sure if understand correctly or assumption totally wrong.

to make more clear, can interpret

n => a(n)? b(n): n*c(n-1); 

as (given definitions provided @ question):

if (n<=1)     return 10; //b(n) else     return n*n-1; //n*c(n-1)=n*n 

notice returns there because of d=...


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -