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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:54:54+00:00 2026-06-17T02:54:54+00:00

I have reviewed about 20 plus pages on the web regarding this error. I

  • 0

I have reviewed about 20 plus pages on the web regarding this error. I have been unable to find a solution to this. I know why the error is occurring but cannot figure out how to fix this. :

I just need to assign an action to my action, but these actions must have an incoming parameter of type string. Any ideas are greatly appreciated as I have been struggling with this for quite some time.

public class CommonDemoHelper
{
    static Action<TextBoxSettings> textBoxSettingsMethod(string txtBoxName);
    static Action<DateEditSettings> dateEditSettingsMethod;
    static Action<LabelSettings> labelSettingsMethod;
    static Action<LabelSettings> wideLabelSettingsMethod;
    static Action<SpinEditSettings> spinEditSettingsMethod;
    static Action<MemoSettings> memoSettingsMethod;

    public static Action<TextBoxSettings> TextBoxSettingsMethod(string txtBoxName)
    {
        get
        {

            if (textBoxSettingsMethod(txtBoxName) == null)
                //Getting error below cannot assign to method group
                textBoxSettingsMethod = CreateTextBoxSettingsMethod(txtBoxName);
            return textBoxSettingsMethod(txtBoxName);
        }
    }

    static Action<TextBoxSettings> CreateTextBoxSettingsMethod(string txtBoxName)
    {
        return settings =>
        {
            settings.ControlStyle.CssClass = "editor";
            settings.ShowModelErrors = true;
            settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
        };
    }
}
  • 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-06-17T02:54:55+00:00Added an answer on June 17, 2026 at 2:54 am

    If a method (or delegate) returns a value, it will be a Func<return_type>, not an action. If it has input parameters (arguments) then it would be a Func<arg1,arg2,arg3,return_type>

    static Func<string, TextBoxSettings> textBoxSettingsMethod;
    
    public static Func<string, TextBoxSettings> GetTextBoxSettingsMethod(string txtBoxName)
    {
        if (textBoxSettingsMethod == null)
            textBoxSettingsMethod = CreateTextBoxSettingsMethod(txtBoxName);
        return textBoxSettingsMethod;
    }
    
    static Func<string, TextBoxSettings> CreateTextBoxSettingsMethod(string txtBoxName)
    {
        ...
    }
    

    Here Func<string, TextBoxSettings> designates a method that accepts a string parameter (input) and returns a TextBoxSettings (output).

    Also, since you need an input argument in TextBoxSettingsMethod it cannot be a property. I changed it to be a method.

    Also I changed the test to make sure that textBoxSettingsMethod is not null (not the result is returning when you execute it). The test textBoxSettingsMethod(txtBoxName) == null calls the method and tests if the return value of type TextBoxSettings is null. If you only want to know whether the method is defined, the test should be textBoxSettingsMethod == null.

    Do not confuse the expression textBoxSettingsMethod which is the method (or delegate) and textBoxSettingsMethod(txtBoxName) which executes the method.


    What is the argument string txtBoxName good for? You are not using it. Do you need different methods for different textboxes? It’s difficult to say.


    UPDATE

    This creates always the same method that returns different settings depending on the textbox name (the argument string txtBoxName is not required, only the argument of the lambda expression tbName which will require an actual parameter value when called):

    static Func<string, TextBoxSettings> CreateTextBoxSettingsMethod()
    {
        return tbName =>
        {
            TextBoxSettings settings;
            switch (tbName) {
                case "textbox1":
                case "textbox2":
                case "textbox3":
                    settings = new TextBoxSettings {
                        TextBoxName = tbName,
                        ControlStyle = "editor",
                        ShowModelErrors = true
                    };
                    settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                    return settings;
                case "textbox4":
                case "textbox5":
                    settings = new TextBoxSettings {
                        TextBoxName = tbName,
                        ControlStyle = "displayer",
                        ShowModelErrors = false
                    };
                    settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.TextOnly;
                    return settings;
                default:
                    return new TextBoxSettings { TextBoxName = tbName };
            }
        };
    }
    

    In contrast, this is a method that creates different methods that return alwas the same settings

    static Func<string, TextBoxSettings> CreateTextBoxSettingsMethod(string txtBoxName)
    {
        switch (txtBoxName) {
            case "textbox1":
            case "textbox2":
            case "textbox3":
                return tbName =>
                {
                    var settings = new TextBoxSettings {
                        TextBoxName = tbName,
                        ControlStyle = "editor",
                        ShowModelErrors = true
                    };
                    settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.ImageWithText;
                    return settings;
                };
            case "textbox4":
            case "textbox5":
                return tbName =>
                {
                    var settings = new TextBoxSettings {
                        TextBoxName = tbName,
                        ControlStyle = "displayer",
                        ShowModelErrors = false
                    };
                    settings.Properties.ValidationSettings.ErrorDisplayMode = ErrorDisplayMode.TextOnly;
                    return settings;
                };
            default:
                return tbName => new TextBoxSettings { TextBoxName = tbName };
        }
    }
    

    UPDATE #2

    Maybe you want this

    static Dictionary<string, Func<string, TextBoxSettings>> textBoxSettingsMethod
        = new Dictionary<string,Func<string,TextBoxSettings>>();
    
    public static Func<string, TextBoxSettings> GetTextBoxSettingsMethod(string txtBoxName)
    {
        Func<string, TextBoxSettings> method;
        if (!textBoxSettingsMethod.TryGetValue(txtBoxName, out method)) {
            method = CreateTextBoxSettingsMethod(txtBoxName);
            textBoxSettingsMethod.Add(txtBoxName, method);
        }
        return method;
    }
    

    You can use it like this:

    Func<string, TextBoxSettings> method;
    TextBoxSettings setting;
    
    method = GetTextBoxSettingsMethod("textbox1");
    setting = method("textbox1");
    
    // or
    
    setting = GetTextBoxSettingsMethod("textbox1")("textbox1");
    
    // or, if you are sure that all the methods have been assigned
    
    method = textBoxSettingsMethod["textbox1"];
    setting = method("textbox1");
    
    // or
    
    setting = textBoxSettingsMethod["textbox1"]("textbox1");
    

    But I’m still not sure why you want to create these methods dynamically. A simple method returning the setting would suffice

    public static TextBoxSettings GetTextBoxSettings(string txtBoxName)
    {
        switch (txtBoxName) {
            // ...
            default:
                return null;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have reviewed several other posts about how to get the CLR to find
Ok I have reviewed several postings here and elsewhere regarding setInterval in jquery/javascript the
< I have reviewed the related questions shown by SO before posting this >
I have a String like this: <p><span class=qlst> <span class=caption>QuickLinks</span> <ul> <li><a href=./journal/molecules/about#aims>Aims</a></li> <li><a
I have reviewed a lot of information about these things, but can't understand what
NOTICE: this question has a ambiguous concept about 'degree'. and I have got my
i have reviewed php manual about the ob_start() ob_end_clean() ob_end_flush(). And i have seen
I have some tasks about sorting arrays in C#. I've been trying everything I
I reviewed my code lot of times and didnt find questions about it. I
have written this little class, which generates a UUID every time an object of

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.