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. array of function

array of function

Scheduled Pinned Locked Moved C#
csharpdata-structurestutorialquestion
7 Posts 6 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.
  • T Offline
    T Offline
    t_nedelchev
    wrote on last edited by
    #1

    Hello everybody. My project is C# project and I want to make an array of function.Is this possible and how to make it? Thanks in advance

    S N P 3 Replies Last reply
    0
    • T t_nedelchev

      Hello everybody. My project is C# project and I want to make an array of function.Is this possible and how to make it? Thanks in advance

      S Offline
      S Offline
      Spunky Coder
      wrote on last edited by
      #2

      Using Delegates and the DynamicInvoke method...

      "Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)

      1 Reply Last reply
      0
      • T t_nedelchev

        Hello everybody. My project is C# project and I want to make an array of function.Is this possible and how to make it? Thanks in advance

        N Offline
        N Offline
        N a v a n e e t h
        wrote on last edited by
        #3

        You can't have array of functions. You can have array of delegates referring to function. It would be like

        delegate void Function();
        Function[] functions = { Function1 , Function2 , Function3 .. };
        functions[0](); // calling 1st function

        :)

        Navaneeth How to use google | Ask smart questions

        T E 2 Replies Last reply
        0
        • N N a v a n e e t h

          You can't have array of functions. You can have array of delegates referring to function. It would be like

          delegate void Function();
          Function[] functions = { Function1 , Function2 , Function3 .. };
          functions[0](); // calling 1st function

          :)

          Navaneeth How to use google | Ask smart questions

          T Offline
          T Offline
          t_nedelchev
          wrote on last edited by
          #4

          can you write me a sample how to define Function1 , Function2 , Function3

          L 1 Reply Last reply
          0
          • T t_nedelchev

            can you write me a sample how to define Function1 , Function2 , Function3

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Take a look at this link[^].

            1 Reply Last reply
            0
            • N N a v a n e e t h

              You can't have array of functions. You can have array of delegates referring to function. It would be like

              delegate void Function();
              Function[] functions = { Function1 , Function2 , Function3 .. };
              functions[0](); // calling 1st function

              :)

              Navaneeth How to use google | Ask smart questions

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

              Heh, you could write some fun code with that:

              FunctionDelegate[] functions = null;
              functions = new FunctionDelegate[]{
              delegate(){
              functions[0]();
              }
              };
              functions[0]();

              Need software developed? Offering C# development all over the United States, ERL GLOBAL, Inc is the only call you will have to make.
              If you don't ask questions the answers won't stand in your way.
              Most of this sig is for Google, not ego.

              1 Reply Last reply
              0
              • T t_nedelchev

                Hello everybody. My project is C# project and I want to make an array of function.Is this possible and how to make it? Thanks in advance

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #7

                Yes, but a List<Delegate> might be better.

                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