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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:43:56+00:00 2026-05-15T17:43:56+00:00

void Afunction(int* outvar) { if(outvar) *outvar = 1337; } note the qualities: it allows

  • 0
void Afunction(int* outvar)
{
    if(outvar)
        *outvar = 1337;
}

note the qualities: it allows you to optionally pass a variable by reference, so that it can be set by the function.

my closest guess would be (ref int? outvar)

but that produces ref (int?) NOT (ref int)? which is what I need

this functionality is hardly a scarcely used feature of c or c++, so I assume there must be some equivalent?
Edit:
so let me try a good example, I think a Colision check function is a prime example, where you have the primary test being whether or not two objects are in contact, then the optional output of the projection vector, calculating the projection vector takes extra time, so you only want to do it if they want it, on the other hand, it usually uses alot of the info calculated when doing the collision test.

bool Collide(colObject obj1, colObject obj2, Vector3* projection)
{

    //do a bunch of expensive operations to determine if there is collision
    if(!collided)return false;
    if(projection != NULL)
    {
        //do more expensive operations, that make use of the above operations already done,
        //to determine the proj vect
        *proj = result;
    }
    return true;
}

note that I am currently just porting c++ code to c#, so I might not have though of any real ‘out of the box’ solutions

  • 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-15T17:43:57+00:00Added an answer on May 15, 2026 at 5:43 pm

    The best you can get in C# is Action<int>, like this:

    void MyFunction(Action<int> valueReceiver) {
        if (valueReceiver != null)
            valueReceiver(1337);
    }
    

    Usage:

    MyFunction(null);
    MyFunction(v => someVariable = v);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.