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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T15:46:21+00:00 2026-06-14T15:46:21+00:00

Can anyone tell me which one is lighter between ref and out . I

  • 0

Can anyone tell me which one is lighter between ref and out. I know the exact difference between ref and out keyword and usage as well.

In my case I can use both ref and out, but wondering the lighter one.

If some one needs to refer please go here and let me know the lighter ones.

Thanks in advance..

  • 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-14T15:46:22+00:00Added an answer on June 14, 2026 at 3:46 pm

    The only difference is a compiler hint.

    … out …

    public static void TestOut(out int test)
    {
        test = 1;
    }
    
    .method public hidebysig static void  TestOut([out] int32& test) cil managed
    {
      // Code size       4 (0x4)
      .maxstack  8
      IL_0000:  ldarg.0
      IL_0001:  ldc.i4.1
      IL_0002:  stind.i4
      IL_0003:  ret
    } // end of method Program::TestOut
    

    … ref …

    public static void TestRef(ref int test)
    {
        test = 1;
    }
    
    .method public hidebysig static void  TestRef(int32& test) cil managed
    {
      // Code size       4 (0x4)
      .maxstack  8
      IL_0000:  ldarg.0
      IL_0001:  ldc.i4.1
      IL_0002:  stind.i4
      IL_0003:  ret
    } // end of method Program::TestRef
    

    … out and ref are effectively the same. The only real difference being that out tells the compiler to expect the value to be set before the method is returned. You could send a value to a function that has an out flag but again the compiler will treat it as an unassigned variable. The runtime doesn’t really care. Both will be created as a pointer to the variable. You are best to use the keyword that describes the functionality you expect with your function. Any optimization that “may” take place in the JITer below this will have near 0 impact on the application.

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

Sidebar

Related Questions

Anyone can tell me which one is better (JAXB or Apache XMLBeans) taking in
Can anyone tell me which one better to use for xml parsing - DOM
Can Anyone tell me the difference between window.location.href and top.location.href ? And also where
Can any one tell me which is more stable? I know each has their
Can anyone tell me which table is considered to be the inner one in
Can anyone tell me what the difference is between these 2 lines of code,
Can anyone kindly tell me which one should I install to develop database applications
Can anyone tell me why I am getting this exception? Well I know why
Can anyone tell me how to make connection in webconfig file (which don't require
Can anyone tell me the .hgignore pattern to track one specific file in a

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.