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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:41:49+00:00 2026-06-04T07:41:49+00:00

C# newbie here. In one of my classes (an Entity class, to be precise),

  • 0

C# newbie here.

In one of my classes (an Entity class, to be precise), I have a delegate that takes in an Entity and another related class:

public delegate void FiringFunc(Entity e, BulletFactory fact)

and a loop in the Entity class that calls this function every frame (if its defined):

FiringFunc firingFunc = null; //defined later
if(firingFunc)
    firingFunc(this, someBulletFactory);    

As one could probably tell, this is a delegate that serves as a bullet firing function (you would code something like a timer for the bullet, the angles to fire at, etc). However, a thought occurred to me: what if I wanted the bullet to have a slight difference, but still remain the same (something like a tad bit slower, a slightly different color, in a different direction, etc). I would have to create another function to serve as the delegate – this seemed wrong to me.

Here is an example of what creating and setting the delegate would look like:

Entity e = new Entity( ... )
e.firingFunc = FiringFunctions.SomeFiringFunctionName;

Is there a way I could add parameters to this? It would be great if I could do something akin to the following:

e.firingFunc = FiringFunctions.SomeFiringFunctionName(someChange1, someChange2);
  • 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-04T07:41:51+00:00Added an answer on June 4, 2026 at 7:41 am

    Try

    e.firingFunc = 
        (Entity e, BulletFactory fact) => 
            FiringFunctions.SomeFiringFunctionName(e, fact, "foo", 5);
    

    This creates a new anonymous function (the lambda) that calls FiringFunctions.SomeFiringFunctionName with the included parameters.

    This assumes that FiringFunctions.SomeFiringFunctionName is defined as:

    public void SomeFiringFunctionName(Entity e, BulletFactory fact, String someString, Int32 someInt) { 
      //...  do whatever here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

newbie doing Java homework here. I have one class named Album which contains the
Mercurial newbie here, I have a simple question. I deleted one of my files
RSpec newbie here. I'm trying to test my models, which have methods that uses
tsql newbie here. I have a table, similar to this one: CarId CarName UserId
Ruby Newbie here, I understand that everything is an object in Ruby, one thing
a newbie question here... I've created an entity data model (.edmx) file in one
Bit of a newbie question here. I have a form and one of it's
Newbie to Fossil (or any other version control system) here. Used a proprietary one
I am a regex newbie and can't seem to figure this one out. Here
Newbie here! My problem is as follows: I have a dynamically populating ul where

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.