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. Delegate Problem

Delegate Problem

Scheduled Pinned Locked Moved C#
helplinux
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.
  • S Offline
    S Offline
    Steve Severance
    wrote on last edited by
    #1

    I am creating a console sort of like quakes in which the user can modify variables and execute commands by typing them into a command line. So I have a Shell class which keeps track of variables and commands that are registered to it. Each command that can be executed has a delegate to the function that it calls when the user types its name in. I want to know if its possible to pass a function name as an arguement to another function, the purpose being that the Shell class would take care of creating the actual delegate. I noticed that in the delegate constructor it uses the parameter void() target, but when i try that it generates a bunch of errors. Any help would be appreciated. Thank you. Steve Not all who wander are lost...

    L 1 Reply Last reply
    0
    • S Steve Severance

      I am creating a console sort of like quakes in which the user can modify variables and execute commands by typing them into a command line. So I have a Shell class which keeps track of variables and commands that are registered to it. Each command that can be executed has a delegate to the function that it calls when the user types its name in. I want to know if its possible to pass a function name as an arguement to another function, the purpose being that the Shell class would take care of creating the actual delegate. I noticed that in the delegate constructor it uses the parameter void() target, but when i try that it generates a bunch of errors. Any help would be appreciated. Thank you. Steve Not all who wander are lost...

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      You'll have to wait for .NET ver2 for anonymous delegates, in the meantime you will have to template each of them, or maybe you can use Reflection.Emit to build delegates dynamically, but that a bit difficult. another suggestion is to go the COntrol.Invoke way, not sure if you can define a delegate with a "params" parameter. Hey leppie! Your "proof" seems brilliant and absurd at the same time. - Vikram Punathambekar 28 Apr '03

      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