Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Delegates

Delegates

Scheduled Pinned Locked Moved C#
salesquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    geekfromindia
    wrote on last edited by
    #1

    I am trying to refer some code at http://mokhan.ca/blog/2007/09/25/SALES+TAXES.aspx[^] I couldnt understand the use of delegates as below:

    private double CalculateAmount( ) {
    double amount = 0d;
    Summary( delegate( ITax tax ) { amount += tax.Amount; } );
    return amount;
    }

    How and why its being used here????

    ~AHAGeek

    E 1 Reply Last reply
    0
    • G geekfromindia

      I am trying to refer some code at http://mokhan.ca/blog/2007/09/25/SALES+TAXES.aspx[^] I couldnt understand the use of delegates as below:

      private double CalculateAmount( ) {
      double amount = 0d;
      Summary( delegate( ITax tax ) { amount += tax.Amount; } );
      return amount;
      }

      How and why its being used here????

      ~AHAGeek

      E Offline
      E Offline
      Ennis Ray Lynch Jr
      wrote on last edited by
      #2

      Summary takes a delegate to calculate tax, however, the Summary method seems out of place since there is nothing to provide a return value to amount meaning the only possible action the summary method can perform is to sum all of the applied taxes.

      Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
      Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
      Most of this sig is for Google, not ego.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups