• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Monday's fascinating C# quiz

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    #11
    Originally posted by sasguru View Post
    I think the fact you didn't explains rather more.
    It's thanks to the degree I did do, that I know how much of a cretin you really are.
    merely at clientco for the entertainment

    Comment


      #12
      Quiz Part II

      If

      Code:
      static Func<int> Wibble()
      {
      int myValue = 0;
      return () => myValue++; 
      }
      static void Main()
      {
      Func<int> wibble= Wibble();
      Console.WriteLine (wibble()); // Prints 0
      Console.WriteLine (wibble()); // Prints 1
      }
      What does

      Code:
      static Func<int> Wibble()
      {
      return() => { int myValue= 0; return myValue++; };
      }
      static void Main()
      {
      Func<int> wibble= Wibble();
      Console.WriteLine (wibble()); // Prints?
      Console.WriteLine (wibble()); // Prints?
      print?

      Comment


        #13
        Originally posted by eek View Post
        It's thanks to the degree I did do, that I know how much of a cretin you really are.
        You're stupid enough to think a degree you did helps you understand people?
        You'd better hope that little business you've got succeeds, because there's no way you're getting to the top otherwise.


        Feck me what has the country done to its education system, that it churns out such imbeciles ?
        Hard Brexit now!
        #prayfornodeal

        Comment


          #14
          Originally posted by DimPrawn View Post
          If

          Code:
          static Func<int> Wibble()
          {
          int myValue = 0;
          return () => myValue++; 
          }
          static void Main()
          {
          Func<int> wibble= Wibble();
          Console.WriteLine (wibble()); // Prints 0
          Console.WriteLine (wibble()); // Prints 1
          }
          What does

          Code:
          static Func<int> Wibble()
          {
          return() => { int myValue= 0; return myValue++; };
          }
          static void Main()
          {
          Func<int> wibble= Wibble();
          Console.WriteLine (wibble()); // Prints?
          Console.WriteLine (wibble()); // Prints?
          print?
          1
          2
          Knock first as I might be balancing my chakras.

          Comment


            #15
            Originally posted by suityou01 View Post
            1
            2
            Nope.

            You clearly don't undertand closures and capturing.

            Comment


              #16
              Originally posted by DimPrawn View Post
              Nope.

              You clearly don't undertand closures and capturing.
              Yep, that's fair. I'm baffled by Lambda expressions as well.
              Knock first as I might be balancing my chakras.

              Comment


                #17
                On reflection, the method takes no arguments, and declares the variable each time setting it to zero so your first example looks wrong to me as how can it ever return anything other than 1?

                Just sayin like.
                Knock first as I might be balancing my chakras.

                Comment


                  #18
                  Originally posted by suityou01 View Post
                  Yep, that's fair. I'm baffled by Lambda expressions as well.
                  That's tomorrow's fascinating C# quiz topic.

                  Comment


                    #19
                    Originally posted by suityou01 View Post
                    On reflection, the method takes no arguments, and declares the variable each time setting it to zero so your first example looks wrong to me as how can it ever return anything other than 1?

                    Just sayin like.
                    As I said, closures and capturing.



                    PS. It's also clear you don't know the difference between ++X and X++

                    Comment


                      #20
                      Originally posted by DimPrawn View Post
                      As I said, closures and capturing.

                      Make for incomprehensible code by the looks of it
                      Knock first as I might be balancing my chakras.

                      Comment

                      Working...
                      X