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

  • Home
  • SEARCH
  • 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 6560201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:25:46+00:00 2026-05-25T13:25:46+00:00

I have some void methods which are static. Is it better to pass variables

  • 0

I have some void methods which are static.

Is it better to pass variables by reference or by value, because I’m passing large amount of text into these variables :

public static void renderText(ref StringBuilder build)
{
  //Do your job.
}

So could someone explain me, what happens when I send a reference of StringBuilder, does it only access this StringBuilder? (It does not copy it right!).

And just in case I’m not changing the value or any other property of input arguments into methods.

So, in this cases where variables are huge enough and not manipulated, should I always send the reference of it, and if yes does it interfere with something?

  • 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-25T13:25:47+00:00Added an answer on May 25, 2026 at 1:25 pm

    Take a look at the following article by Jon Skeet in which he thoroughly explains the difference between passing by reference or by value.

    Parameter passing in C#

    or this blog post which illustrates the former article:

    http://rapidapplicationdevelopment.blogspot.com/2007/01/parameter-passing-in-c.html

    The last article actually uses the StringBuilder type in its examples, so you can clearly see what’s going on in your case. If you pass in the StringBuilder type by reference you’ll get this:

    Reference type passed by reference:

    enter image description here

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

Sidebar

Related Questions

I have a static class, which methods is called from instances of another class.
I have many methods which are calling using Delegate.DynamicInvoke . Some of these methods
i have two classes which have some common methods like funcA(), funcB() and some
I have some classes layed out like this class A { public virtual void
Suppose I have a class that processes some data: class SomeClass { public: void
Say we have: class Base { virtual void f() {g();}; virtual void g(){//Do some
I have the following code: Some functions: A::A(int i_a) {cout<<int Ctor\n;} //conversion constructor void
I have some ASP.NET web services which all share a common helper class they
I have some C# / asp.net code I inherited which has a textbox which
I have an exe referencing a dll. In the dll there's some methods, the

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.