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 6111947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:41:21+00:00 2026-05-23T14:41:21+00:00

I am considering storing methods inside of a dictionary (using a friendly user-readable string

  • 0

I am considering storing methods inside of a dictionary (using a friendly user-readable string as a key) so that a message like “echo, hello world” can be sent to the server and the Server will know to call: echo(string message) and pass in “hello world”.

Pseudo code:

public delegate void NetCommand(object param);

void MyNetCommand(object param)
{
  string s = param as string;

  Console.WriteLine(s);
}

Dictionary<string, NetCommand> commands = new Dictionary<string, NetCommand>();

static void Main(string[] args)
{
  commands.Add("echo", MyNetCommand);
} 

void OnReceiveSomeImaginaryMessageAfterItsBeenProcessed(string friendly, object param)
{
  commands[friendly]();
}

My question is: is this a good idea? Are there any drawbacks to doing this? Or, is this just the “wrong” way to do something that already has a desirable solution?

  • 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-23T14:41:22+00:00Added an answer on May 23, 2026 at 2:41 pm

    I personaly think it’s elegant enough solution. The single think I will personally change is: instead puting into the Value of dictionary a delefate, put a class object. In this case yuo can easily support in the future increasing complexity of your code.

    public abstract class MyAbstractNetCommand {   
    
         public abstract void ExecuteCommand();
    } 
    
    public class ConcreteCommand : MyAbstractNetCommand {
    
        /*Here additional ConcreteCommand specific methods and state members*/
    
        public override ExecuteCommand() {
           // concrete iplementation
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm considering storing some date values as ints. i.e 201003150900 Excepting the fact that
I have a string that is defined as one or more dot-separated integers like
considering this example: public static void main(final String[] args) { final List<String> myList =
Considering following code public class A { public static void main(String[] args) { new
Which one is recommended considering readability, memory usage, other reasons? 1. String strSomething1 =
Considering this code, can I be absolutely sure that the finally block always executes,
Possible Duplicate: Differences in string compare methods in C# In .NET there are many
I have a java applet. A class inside that applet is creating a thread
I have a small framework that is logging some info and debug messages using
Considering I have two arrays for example: String[] array1 = new String[10]; int[] array2=

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.