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

  • Home
  • SEARCH
  • 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 4012742
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:17:07+00:00 2026-05-20T09:17:07+00:00

Can someone provide me an example of how maybe I store different functions in

  • 0

Can someone provide me an example of how maybe I store different functions in a dictionary with int as a key and function as value. So then I could easly call function as following:

functionsDictionary[123](string);

Note all functions in dictionary will take only one input which is string. And will have no return.

  • 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-05-20T09:17:07+00:00Added an answer on May 20, 2026 at 9:17 am

    It sounds like you’re after

    Dictionary<int, Action<string>>
    

    or possibly (based on your title)

    Dictionary<uint, Action<string>>
    

    Sample:

    using System;
    using System.Collections.Generic;
    
    class Test
    {
        static void Main()
        {
            var dictionary = new Dictionary<int, Action<string>>
            {
                { 5, x => Console.WriteLine("Action for 5: {0}", x) },
                { 13, x => Console.WriteLine("Unlucky for some: {0}", x) }
            };
    
            dictionary[5]("Woot");
            dictionary[13]("Not really");
    
            // You can add later easily too
            dictionary.Add(10, x => Console.WriteLine("Ten {0}", x));
            dictionary[15] = x => Console.WriteLine("Fifteen {0}", x);
    
            // Method group conversions work too
            dictionary.Add(0, MethodTakingString);
        }
    
        static void MethodTakingString(string x)
        {
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone provide a regular expression for parsing name/value pairs from a string? The
Can someone provide a simple explanation of methods vs. functions in OOP context?
can someone provide an example or point me to where I can learn how
can someone please provide an example of how to use uBLAS product to multiply
Can someone provide the download link for SQL Server Reports add-in for Visual Studio
Can someone provide some light on how to do this? I can do this
Hoping someone can provide an answer with this, although it's not 100% programming related.
Can someone give an example of a good time to actually use unsafe and
Can someome provide code or pseudo-code for how the paging links on StackOverflow are
Can someone show me how to implement a recursive lambda expression to traverse a

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.