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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:49:05+00:00 2026-05-26T01:49:05+00:00

I cannot try rigth now, but I am sure, someone knows: void func(out MyType

  • 0

I cannot try rigth now, but I am sure, someone knows:

void func(out MyType A) {
    A = new MyType(); 

    // do some other stuff here

    // take some time ... and return
}

When I call this in an asynchronous manner like that:

MyType a; 
func(out a); 

will a be altered immediately, once A is assigned in the function? Or is the new object reference assigned to a only when the function returns?

Are there any specifications if I want to relay on the currently implemented behavior?

  • 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-26T01:49:06+00:00Added an answer on May 26, 2026 at 1:49 am

    It’s assigned once A is assigned in the function. The use of out provides a reference to whatever you passed in, which means it gets modified whenever it is modified in the method.

    An extract from the C# language spec:

    5.1.6 Output parameters

    A parameter declared with an out modifier is an output parameter.

    An output parameter does not create a new storage location. Instead, an output parameter represents the same storage location as the variable given as the argument in the function member or delegate invocation. Thus, the value of an output parameter is always the same as the underlying variable.

    The following definite assignment rules apply to output parameters. Note the different rules for reference parameters described in §5.1.5.

    · A variable need not be definitely assigned before it can be passed as an output parameter in a function member or delegate invocation.

    · Following the normal completion of a function member or delegate invocation, each variable that was passed as an output parameter is considered assigned in that execution path.

    · Within a function member or anonymous function, an output parameter is considered initially unassigned.

    · Every output parameter of a function member or anonymous function must be definitely assigned (§5.3) before the function member or anonymous function returns normally.

    Within an instance constructor of a struct type, the this keyword behaves exactly as an output parameter of the struct type (§7.6.7).

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

Sidebar

Related Questions

I can fix the below exception with a try-catch loop but I cannot understand
Try as I might I cannot get my head around what the IteratorIterator class
No matter how I try, I cannot mimic the clean syntax of Rhino Mocks,
I cannot figure out how to change the title bar icon (the icon in
I cannot figure out a way to disable a container AND its children in
All, I must have a fundamental neuron missing, but I cannot get a simple
I created a virtualenv around my project, but when I try to activate it
I barely got into ASP.Net webforms when MVC came out, and now I'm ready
I have now tried to get this to work for a few hours but
I just downloaded the new xcode, 3.2.6 to try with the new sdk. I

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.