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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:34:37+00:00 2026-06-17T16:34:37+00:00

I have a delegate which looks like the following: public delegate bool ApprovalPrompt(ApprovalType type,

  • 0

I have a delegate which looks like the following:

public delegate bool ApprovalPrompt(ApprovalType type, int receipt, params string[] info);

I accept a delegate of this type as a parameter to the function I want to call. However, in one particular calling function, I want to pass some extra data to the function which matches this delegate.

Here’s the signature of the implementing function:

private static bool LogApprovalNeeded(FraudFilterUtilities.ApprovalType type, int receipt, params string[] info)

and it’s being called as follows:

PrepareReceipt(LogApprovalNeeded);

I’d like it to be:

private static bool LogApprovalNeeded(Customer cust, FraudFilterUtilities.ApprovalType type, int receipt, params string[] info)

which ideally would be used as follows:

PrepareReceipt(LogApprovalNeeded(myCustomer))

How can I accomplish such a thing? I’d rather not need to declare a field in the class just to hold the Customer parameter between one function and the callback…

  • 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-17T16:34:39+00:00Added an answer on June 17, 2026 at 4:34 pm

    You can use a lambda to “curry” your function:

    PrepareReceipt((type, receipt, info) => 
        LogApprovalNeeded(myCustomer, type, receipt, info))
    

    Currying a function is the formal term for storing a reference to a function but with one or more of the parameters “fixed”, thus altering the signature of the method.

    You can also use a lambda when the signature of your function doesn’t need all of the arguments that the delegate is providing; you can effectively discard parameters by not passing forward all of the arguments in the lambda.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Application Delegate class with a enumeration which looks like this: typedef
I have a delegate that looks like this: public delegate byte[] CopyPixelOperation(byte[] pixel); It
I have the following delegate method which is listening for when text changes in
When i have delegate like public delegate void PrintMe(); (1) PrintMe a = delegate()
I have a native api function which looks like: DWORD WINAPI WlanRegisterNotification( __in HANDLE
I have the following code: public void SetMove(Position3D pos, float time, float linearity, bool
I have a property that looks like this: @property (weak, nonatomic) id<NavigationControllerDelegate> delegate; But
I have a Silverlight delegate which gets an ObservableCollection in the EventArgs Result. The
I have my main application delegate which contains a method that returns an object.
Can we have same delegate for two events ? which have same number 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.