Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9269203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:03:26+00:00 2026-06-18T15:03:26+00:00

static uint Fibonacci(uint n) { return n <= 1 ? n : Fibonacci(n –

  • 0
 static uint Fibonacci(uint n)
    {
        return n <= 1 ? n : Fibonacci(n - 1) + Fibonacci(n - 2);
    }

Func<uint> fibN = () => Fibonacci(n);
Func<int, int, int> add = (a, b) => a + b;

I understand add function syntax: it returns int result of a + b statement into which int a and b parameters “goes”.

But why fibN function has empty parameter block () ? Doesn’t n “goes” to this function as parameter? Please help me to grasp some understanding of this moment.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:03:27+00:00Added an answer on June 18, 2026 at 3:03 pm

    Consider the following code:

    class Program
    {
        static void Main(string[] args)
        {
            Func<uint> fibN = () => Fibonacci(n);
        }
    
        static uint Fibonacci(uint n)
        {
            return n <= 1 ? n : Fibonacci(n - 1) + Fibonacci(n - 2);
        }
    }
    

    It does not comile, as soon as there is no variable n of a suitable type to be used. However if you add:

    uint n = 5;
    

    into Main method or

    static uint n = 5;
    

    to the class, the code will compile.


    Let’s disassemble. For the following code:

    static void Main(string[] args)
    {
        uint n = 3;
        Func<uint> fibN = () => Fibonacci(n);
    }
    

    we get:

    .method private hidebysig static void  Main(string[] args) cil managed
    {
      .entrypoint
      .maxstack  3
      .locals init ([0] class [mscorlib]System.Func`1<uint32> fibN,
               [1] class Utils.Program/'<>c__DisplayClass1' 'CS$<>8__locals2')
      IL_0000:  newobj     instance void Utils.Program/'<>c__DisplayClass1'::.ctor()
      IL_0005:  stloc.1
      IL_0006:  nop
      IL_0007:  ldloc.1
      IL_0008:  ldc.i4.3
      IL_0009:  stfld      uint32 Utils.Program/'<>c__DisplayClass1'::n
      IL_000e:  ldloc.1
      IL_000f:  ldftn      instance uint32         Utils.Program/'<>c__DisplayClass1'::'<Main>b__0'()
      IL_0015:  newobj     instance void class [mscorlib]System.Func`1<uint32>::.ctor(object,
                                                                                  native int)
      IL_001a:  stloc.0
      IL_001b:  nop
      IL_001c:  ret
    } // end of method Program::Main
    

    In this code you may find a hidden class c__DisplayClass1, in which we can see a public field of type uint32 named n:

    .field public uint32 n
    

    and method <Main>b__0:

    .method public hidebysig instance uint32 
        '<Main>b__0'() cil managed
    {
      .maxstack  1
      .locals init ([0] uint32 CS$1$0000)
      IL_0000:  ldarg.0
      IL_0001:  ldfld      uint32 Utils.Program/'<>c__DisplayClass1'::n
      IL_0006:  call       uint32 Utils.Program::Fibonacci(uint32)
      IL_000b:  stloc.0
      IL_000c:  br.s       IL_000e
      IL_000e:  ldloc.0
      IL_000f:  ret
    } // end of method '<>c__DisplayClass1'::'<Main>b__0'
    

    which actually calls Fibonacci and passes the n variable. So the compiler extracted the local variable n into a separate class; as well as extracted lambda into a method of this class. In the end it looks like you assign c__DisplayClass1.<Main>b__0 to Func<uint> fibN.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider following program: static void Main (string[] args) { int i; uint ui; i
If I write the function: public static uint FindAUint(double firstParam) { } I can
class Frame { static int X; static int Y; static uint Color; static protected
My Solution [DllImport(user32.dll)] public static extern bool RegisterHotKey(IntPtr hWnd, int id, uint fsModifiers, int
I've got the following function: public static extern uint FILES_GetMemoryMapping( [MarshalAs(UnmanagedType.LPStr)] string pPathFile, out
static void testlock() { for(int i=0;i<10000000;i++) { float f=2.0/i; } } static void TEST()
static inline void *__memset(void *s, char c, size_t n) { int d0, d1; asm
I'm writing a function that takes an Enum and casts it to uint .
How can I write this in Delphi code? [DllImport(FT_ND_API.dll)] public static extern uint epas_CreateContext(out
I have this code: - (NSString *) calculate: (uint) position { static NSArray *

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.