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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:18:06+00:00 2026-05-16T10:18:06+00:00

Pretty straight forward. MSDN states that you can use ref, but not out for

  • 0

Pretty straight forward. MSDN states that you can use ref, but not out for partial methods. I’m just curious as to the why? It was my understanding that when code is compiled, the partials are merged, so what is up with the restriction? Is there more to partial than just making code files cleaner and organized (i.e. eyecandy)?

Reference: MSDN Article – “Partial methods can have ref but not out parameters.”

  • 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-16T10:18:07+00:00Added an answer on May 16, 2026 at 10:18 am

    You got to consider what happens if the partial method isn’t implemented.

    What happens then is that all calls to the method is just stripped out as though they never happened.

    So for a method using out, it would look like this:

    stream s;
    GetStream(out s);
    s.Write(...);
    

    and be compiled as though it said this:

    stream s;
    s.Write(...);
    

    This code is not allowed because s has not been initialized. The guarantee that the variable would be initialized by the time you try to call the Write method on it was tied up with the call to GetStream.

    It is the same with methods returning data. Since the entire method call is just not compiled if you haven’t implemented the partial method, you need to consider what you can and cannot do and still leave the code that calls it valid. In terms of out and return values, it has the potential of leaving the calling code invalid or incomplete, so it is not allowed.

    As for ref, that is valid since the initialization has been taken care of by the calling code:

    stream s = null;
    GetStream(ref s); // may be stripped out
    if (s != null)
        s.Write(...);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a pretty straight forward question but I can't seem to figure out
Hopefully this is pretty straight forward, just can't work it out. I need to
This might be pretty straight forward. But i can't figure out a stable solution.
Thought it was pretty straight forward. But I get a iterator not dereferencable errro
Pretty straight forward question, but I can't find a way to do it. When
Pretty straight forward, I just can't get it to work. What can I do
So, this is pretty straight forward, but I'm not sure how to do it.
This should be pretty straight forward but I can't seem to get my newbie
i think this is a pretty straight forward problem , but i still can
Pretty straight forward I suppose. Getting the background position is easy, but just getting

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.