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
Post a Comment