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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:23:32+00:00 2026-06-05T13:23:32+00:00

I have many methods similar to this: void GetColorSky(out float r, out float g,

  • 0

I have many methods similar to this:

 void GetColorSky(out float r, out float g, out float b)
 void GetColorGround(out float r, out float g, out float b)

“Similar” meaning they have the exact same method header excluding the method name.
I also have several “colourPicker” controls, that accept R, G, B values.

I am trying to create a method that accepts a method as one of it’s parameters, like so:

UpdateColourPicker(ColorPicker cp, CustomMethod cMethod)

and call it as follows:

UpdateColourPicker(cpSky, GetColorSky)
UpdateColourPicker(cpGround, GetColorGround)

What is the correct syntax for out and Action together?
I’ve looked at this question but I still haven’t managed.

Thanks!

  • 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-05T13:23:33+00:00Added an answer on June 5, 2026 at 1:23 pm

    Taking cue from that linked answer, this will work:

    public delegate void GetColorDel(out float r, out float g, out float b);
    
    void UpdateColourPicker(ColorPicker cp, GetColorDel cMethod) { }
    
    UpdateColourPicker(cpSky, GetColorSky);
    UpdateColourPicker(cpGround, GetColorGround);
    

    Unfortunately, as stated in the answer to the question you link, Action and Func do not work with out and ref. This is simply because Action and Func are just delegate definitions stated (quite a few times to offer different overloads) with generics in the BCL. Adding ref and out variants would quickly cause re-definition compiler errors.

    The full sample:

    class Program
    {        
        public delegate void GetColorDel(out float r, out float g, out float b);
    
        static void Main(string[] args)
        {
            UpdateColourPicker(null, GetColorSky);
            UpdateColourPicker(null, GetColorGround);
    
            Console.Read();
        }
    
        static void GetColorSky(out float r, out float g, out float b) 
        {
            r = g = b = 0f;
            Console.WriteLine("sky"); 
        }
    
        static void GetColorGround(out float r, out float g, out float b) 
        {
            r = g = b = 0f;
            Console.WriteLine("ground"); 
        }
    
        static void UpdateColourPicker(object cp, GetColorDel cMethod) 
        {
            float r, g, b;
            cMethod(out r, out g, out b);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a test method created using Selenium, something similar to this: [TestFixture] public
I have many js methods that uses global variables like: function DoSomething() { var
I have a class with many methods. How can I modify my methods so
I have a WCF service with many methods. I would like that after executing
I have a toolkit that has many methods often taking Expression<Func<T,TProperty>> as parameters. Some
I have an ActiveX/COM DLL. It contains many methods and properties. I would like
I have a form that has many long-methods. My quest is: What is the
Occasionally , we have to write methods that receive many many arguments , for
I have a question about Criteria method, one-to-many relation to the database, 'one' is
Possible Duplicate: Define a method that has many (or infinite) arguments I have the

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.